Skip to content
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

fix: suppress addWatchFile invalid phase error #14751

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 25, 2023

Description

Fix https://github.com/vitejs/vite/actions/runs/6624843925/job/17994626864?pr=11151

The error happens at watchFile

packageCache.set = (id, pkg) => {
if (!isInNodeModules(pkg.dir) && !watchedDirs.has(pkg.dir)) {
watchedDirs.add(pkg.dir)
watchFile(path.join(pkg.dir, 'package.json'))

While we do swap to a stub after the build ends at

buildEnd() {
watchFile = watchFileStub
},

Rollup only calls buildEnd here https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/rollup/rollup.ts#L83, but the "generate phase" (that's used to track and trigger the error) is set at https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/Graph.ts#L120 (inside graph.build(), which is called in the code above the first Rollup link. Additionally, here's addWatchFIle's error guard https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/utils/PluginContext.ts#L56-L61

So there's a short in-between phase where Rollup declares the start of "generate phase" but haven't ended the build with buildEnd yet. This PR suppresses the error for now as there's no way to detect the phase.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@stackblitz
Copy link

stackblitz bot commented Oct 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev merged commit c3622d7 into main Oct 26, 2023
10 checks passed
@patak-dev patak-dev deleted the fix-watch-phase branch October 26, 2023 02:41
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.

None yet

2 participants