-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Vite crash when switching between two significantly different branches - RangeError: Set maximum size exceeded #12062
Description
Describe the bug
In our case, by running vite in local dev and switching between our release branches with git checkout then we see the shell/vite crash and the browser die. It seems like HMR is not able to keep up with so many files changing so quickly.
Examination of the stack trace
It seems like since so many files change at the same time, it triggers this event handler many times:
vite/packages/vite/src/node/server/index.ts
Lines 506 to 511 in 8c87af7
| watcher.on('add', (file) => { | |
| handleFileAddUnlink(normalizePath(file), server) | |
| }) | |
| watcher.on('unlink', (file) => { | |
| handleFileAddUnlink(normalizePath(file), server) | |
| }) |
The event handler is calling handleFileAddUnlink:
vite/packages/vite/src/node/server/hmr.ts
Line 195 in 167753d
| export async function handleFileAddUnlink( |
Which subsequently calls updateModules:
vite/packages/vite/src/node/server/hmr.ts
Line 204 in 167753d
| updateModules( |
Calls propagateUpdate at this line over-and-over again (10+ times according to stack trace):
vite/packages/vite/src/node/server/hmr.ts
Line 313 in 167753d
| if (propagateUpdate(importer, boundaries, subChain)) { |
Then calls propagateUpdate one more time before hitting the RangeError:
vite/packages/vite/src/node/server/hmr.ts
Line 148 in 167753d
| const hasDeadEnd = propagateUpdate(mod, boundaries) |
Finally, the exception/crash is triggered at this point:
vite/packages/vite/src/node/server/hmr.ts
Line 246 in 167753d
| boundaries.add({ |
Reproduction
not yet...
Steps to reproduce
- Checkout branch "A"
- Run yarn vite
- Checkout branch "B" that is significantly different than "A"
- Watch in the terminal and browser for the crash
System Info
Vite 4.1.1Used Package Manager
yarn
Logs
boundaries.add({
^
RangeError: Set maximum size exceeded
at Set.add (<anonymous>)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38291:20)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at updateModules (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38231:28)
at handleFileAddUnlink (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38271:9)
at FSWatcher.<anonymous> (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:61281:9)
at FSWatcher.emit (node:events:525:35)
at FSWatcher.emitWithAll (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50325:8)
at FSWatcher._emit (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50417:8)
at FSWatcher._remove (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50680:50)
at FsEventsHandler.handleEvent (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49529:16)
at FsEventsHandler.checkExists (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49517:12)
I think the browser crash is possibly due to how HMR tries to do a full reload of the page but because the vite server crashed it shows Chrome as unavailable:

Possibly related stack trace that doesn't cause total crash
The stack trace below can happen but in an overlay and appears to be more recoverable.
When a lot of files change but not as many as when switching between our release branches, then it doesn't lead to a complete vite crash but it has this stack trace that displays in the vite overlay. I suspect that the stack trace below and the one above have a related cause (i.e., lots of files change):
Set maximum size exceeded
at Set.add (<anonymous>)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38291:20)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at propagateUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38347:13)
at updateModules (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38231:28)
at handleHMRUpdate (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:38219:5)
at FSWatcher.<anonymous> (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:61267:23)
at FSWatcher.emit (node:events:525:35)
at FSWatcher.emitWithAll (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50325:8)
at FSWatcher._emit (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:50417:8)
at FsEventsHandler.handleEvent (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49551:14)
at FsEventsHandler.addOrChange (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js:49501:8)
at FsEventsHandler.checkExists (file:///xxx/node_modules/vite/dist/node/chunks/dep-3007b26d.js
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.