Skip to content

fix(core): reset compile done state on watch restart - #8538

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/fix-compile-done
Sep 24, 2026
Merged

chenjiahan merged 1 commit into
mainfrom
chenjiahan/fix-compile-done

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Motivation

In multi-environment dev or watch builds, a compiler can restart without another invalid hook, causing onAfterDevCompile or onAfterBuild to 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T03:28:22.418055Z 1fed46e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +351 to +354
compiler.hooks.watchRun.tap(
{ name: 'rsbuild:done', stage: -Infinity },
resetDoneState,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chenjiahan chenjiahan Sep 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chenjiahan
chenjiahan merged commit 2769025 into main Sep 24, 2026
7 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/fix-compile-done branch September 24, 2026 03:50
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

⌂ 换网址