Repository navigation
fix(core): reset compile done state on watch restart - #8538
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fed46e02b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| compiler.hooks.watchRun.tap( | ||
| { name: 'rsbuild:done', stage: -Infinity }, | ||
| resetDoneState, | ||
| ); |
There was a problem hiding this comment.
Cancel pending all-done decisions on restart
When one child's done handler has already captured lastCompilerDone = true and is awaiting an asynchronous onAfterEnvironmentCompile, another child can enter this watchRun and decrement doneCompilers, but the pending handler still invokes onDone using its captured value. Consequently, in a multi-environment dev/watch build with an async after-environment hook, onAfterDevCompile or onAfterBuild can still fire after a compiler has restarted but before its replacement stats are ready. Track and invalidate the pending completion generation, and cover this interleaving through the real watch lifecycle rather than only manually invoking hooks.
AGENTS.md reference: AGENTS.md:L6-L6
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
It also occurs before this PR. I'll consider addressing it in a separate follow-up, keeping this PR focused on resetting completion state when a compiler restarts without another invalid hook.
Motivation
In multi-environment dev or watch builds, a compiler can restart without another
invalidhook, causingonAfterDevCompileoronAfterBuildto fire early with stale Stats. This is the Rsbuild counterpart to web-infra-dev/rspack#15865.Changes
Reset the compiler's completion state at the start of
watchRun, before asynchronous plugin hooks. Add a minimal dev regression test covering a restart without invalidation while another compiler finishes.