vite
vite copied to clipboard
rollup is watching C:\ in windows environment, if dynamic imports are used
Describe the bug
I'm not totaly sure if I'm on the right track here:
We noticed the node process terminated regulary when we ran our script for vite in watch mode (vite build --watch
) after migrating to vite 3.x.
We are under the impression, that if you use dynamic imports in an windows environment, rollup is also watching C:\
. This seems to lead to the error.
Sadly, the termination is not deterministic. At some point in time, after a change, the process just craches. I suspect the build time has something to do with the crash: longer build times seem to favor an error.
After digging into rollup, we noticed that at some point the path /@vite/dynamic-import-helper
is watched. Somehow, this path is 'translated' into C:\
in my Windows environment.
I created a breakpoint in node_modules\rollup\dist\es\shared\watch.js
in async _addToNodeFs(path, initialAdd, priorWh, depth, target)
in line 3184
This does only happen if dynamic imports are used.
I am not entirely sure if both behaviors (watching C:\
and crashing) are related.
Reproduction
https://github.com/HerrDietz/vite-crash-reproducer/
System Info
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 3.65 GB / 15.88 GB
Binaries:
Node: 16.17.0 - C:\Java\nodejs\node.EXE
npm: 8.11.0 - C:\Java\nodejs\npm.CMD
Browsers:
Chrome: 105.0.5195.102
Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.33)
Used Package Manager
npm
Logs
Click to expand!
build started...
✓ 98 modules transformed.
dist/vite-watch-reproducer.mjs 0.57 KiB / gzip: 0.35 KiB
dist/lazy-loaded-foo.90063862.mjs 0.11 KiB / gzip: 0.10 KiB
built in 42ms.
build started...
✓ 99 modules transformed.
dist/vite-watch-reproducer.mjs 0.57 KiB / gzip: 0.35 KiB
dist/lazy-loaded-foo.90063862.mjs 0.11 KiB / gzip: 0.10 KiB
built in 49ms.
build started...
✓ 100 modules transformed.
dist/vite-watch-reproducer.mjs 0.57 KiB / gzip: 0.35 KiB
dist/lazy-loaded-foo.90063862.mjs 0.11 KiB / gzip: 0.10 KiB
built in 34ms.
Waiting for the debugger to disconnect...
node:events:491
throw er; // Unhandled 'error' event
^
Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (file:///C:/foo/bar/vite-watch-reproducer/node_modules/rollup/dist/es/shared/watch.js:4397:10)
at ReaddirpStream.NodeFsHandler$1._boundHandleError (file:///C:/foo/bar/vite-watch-reproducer/node_modules/rollup/dist/es/shar
ed/watch.js:2873:43)
at ReaddirpStream.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4082,
code: 'EBUSY',
syscall: 'lstat',
path: 'C:\\DumpStack.log.tmp'
}
Waiting for the debugger to disconnect...
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] 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.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.