Skip to content

fix: suppress addWatchFile invalid phase error#14751

Merged
patak-cat merged 1 commit intomainfrom
fix-watch-phase
Oct 26, 2023
Merged

fix: suppress addWatchFile invalid phase error#14751
patak-cat merged 1 commit intomainfrom
fix-watch-phase

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

@bolt-new-by-stackblitz
Copy link

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

@patak-cat patak-cat merged commit c3622d7 into main Oct 26, 2023
@patak-cat patak-cat 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.

2 participants