-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUGFIX #6679 - workaround for tiny-lr not reloading on empty files arguments #6690
Conversation
Let me summarize to make sure I understand this correctly (correct me if I mis-understand): In-order to recover post error, if no files have changed (since we just restored to the original current state) we must reload anyways, as we are still on the error screen. (if so, this seems reasonable) |
this._hasCompileError = true; | ||
files = ['LiveReload due to compile error']; | ||
} else if ( this._hasCompileError) { | ||
this._hasCompileError= false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace between _hasCompileError
and =
@@ -137,8 +137,15 @@ class LiveReloadServerTask extends Task { | |||
let previousTree = this.tree; | |||
let files; | |||
|
|||
if ( results.stack ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra whitespace between (
and results.stack
and )
;
if ( results.stack ) { | ||
this._hasCompileError = true; | ||
files = ['LiveReload due to compile error']; | ||
} else if ( this._hasCompileError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unbalanced whitespace
@stefanpenner your understanding of the issue is correct |
f197755
to
147f599
Compare
I've fixed whitespace problems and squashed commits into single one. |
147f599
to
c21370f
Compare
@gandalfar thanks! This looks reasonable, but we likely need a unit test covering it. If you need help, let me know. We can likely lend a hand if needed. |
Can you suggest what should be part of the test? I don't think I can capture tiny-lr output. I can assert against error stack trace and this._hasError. |
likely just ensure https://github.com/ember-cli/ember-cli/pull/6690/files#diff-60cfa3bc4236a25e0793052851917a47R164 gets invoked with the expected value. |
I've added test that checks for
with custom |
9d1245b
to
f8eefba
Compare
I've squashed commits and made sure it still applies to current master. Is there anything else I can do? |
@gandalfar this looks great! Sorry for letting this sit. |
re-running appvevor, will merge when green. |
c7353e8
to
4ced5ab
Compare
…files arguments
490077f
to
503ede1
Compare
finally 🍏 ! @homu r+ |
📌 Commit 503ede1 has been approved by |
BUGFIX #6679 - workaround for tiny-lr not reloading on empty files arguments In a situation when you revert failed compile attempt in `broccoli-persistent-filter`'s `processString`, ``` // lib/tasks/server/livereload-server.js didChange(results) { ... this.tree = new FSTree.fromEntries(this.getDirectoryEntries(results.directory), {sortAndExpand: true}); files = previousTree.calculatePatch(this.tree) .filter(isNotRemoved) .filter(isNotDirectory) .map(relativePath) .filter(isNotSourceMapFile); ``` the result of `files` is `[]`. This gets passed to `this.liveReloadServer().changed({` which doesn't trigger new websocket push, because there's nothing to notify clients about. This PR works around this by catching the fact that there was a compilation error and forcing reload on next `didChange`. I'm not sure if it's possible to write test for this as `tiny-lr`'s [`changed`](https://github.com/mklabs/tiny-lr/blob/master/lib/server.js#L220) doesn't return. I've got test written for the Error handling portion of the functionality. This might be a too complicated approach, but I'm not familiar with whole system enough to see any other options. Because it doesn't different between reasons for errors, it also fixes #6242.
☀️ Test successful - status |
In a situation when you revert failed compile attempt in
broccoli-persistent-filter
'sprocessString
,the result of
files
is[]
.This gets passed to
this.liveReloadServer().changed({
which doesn't trigger new websocket push, because there's nothing to notify clients about.This PR works around this by catching the fact that there was a compilation error and forcing reload on next
didChange
.I'm not sure if it's possible to write test for this as
tiny-lr
'schanged
doesn't return. I've got test written for the Error handling portion of the functionality.This might be a too complicated approach, but I'm not familiar with whole system enough to see any other options. Because it doesn't different between reasons for errors, it also fixes #6242.