fix: Avoid auto-reload for recently created source directory#3697
Open
Rob--W wants to merge 1 commit intomozilla:masterfrom
Open
fix: Avoid auto-reload for recently created source directory#3697Rob--W wants to merge 1 commit intomozilla:masterfrom
Rob--W wants to merge 1 commit intomozilla:masterfrom
Conversation
Watchpack has a bug that caused it to dispatch change events for files that were created recently (up to 2 seconds before now). This can trigger an unwanted auto-reload, e.g. in the scenario of an extension developer building an extension and using `web-ext run` to immediately launch that built package. Fixing this bug caused test.cli.run-target-chromium.js to time out because the "with auto-reload" test got stuck, because it waited until "The extension will reload if any source file changes" was logged before writing a file to trigger auto-reload, but that message was logged before the watcher was registered. To fix that test issue, move the logging after initializing the reload strategy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Watchpack has a bug that caused it to dispatch change events for files that were created recently (up to 2 seconds before now). This can trigger an unwanted auto-reload, e.g. in the scenario of an extension developer building an extension and using
web-ext runto immediately launch that built package.For more details on the Watchpack issue, see webpack/watchpack#295.
Since
startTime's documented use is to detect changes in the past, and we passDate.now(), we can drop it without negatively affecting the desired behavior. Auto reload is still expected to work.Note: this PR also includes another change (moving "The extension will reload if any source file changes" log after initializing the watcher), because the fix to the watchpack bug caused
test.cli.run-target-chromium.jsto get stuck (because it was awaiting a reload that never came due to the watcher not having been initialized when the test triggered the file write).