Skip to content

fix: Avoid auto-reload for recently created source directory#3697

Open
Rob--W wants to merge 1 commit intomozilla:masterfrom
Rob--W:watcher-watchpack-startTime-fix
Open

fix: Avoid auto-reload for recently created source directory#3697
Rob--W wants to merge 1 commit intomozilla:masterfrom
Rob--W:watcher-watchpack-startTime-fix

Conversation

@Rob--W
Copy link
Copy Markdown
Member

@Rob--W Rob--W commented Apr 26, 2026

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.

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 pass Date.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.js to 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).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant