-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Describe the bug
When using Terser and Workers on non-trivial dependencies, vite seems to exhibit a concurrency bug which causes terser to error and forces the bundle to stop. However, this bug is particularly confusing for developers because it doesn't mention terser at all! Instead, it says
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(vite:worker) transform "vitebug/node_modules/.pnpm/monaco-editor@0.34.0/node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js?worker"
Ideally whatever error terser is causing should be correctly logged (and terser shouldn't error on this worker bundle).
I've tried to figure out what error is stopping the build but it seems like importing terser just immediately halts the worker with no errors logged
I also tested this bug on stackblitz and it seems that it is missing the on("beforeExit") nodejs feature so doesn't log anything and instead silently outputs nothing: https://stackblitz.com/edit/vite-workers-bug
Reproduction
https://github.com/modderme123/vitebug/
System Info
System:
OS: macOS 12.5
CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
Memory: 17.69 MB / 16.00 GB
Shell: 3.5.1 - /usr/local/bin/fish
Binaries:
Node: 18.7.0 - /usr/local/bin/node
npm: 8.16.0 - /usr/local/bin/npm
Browsers:
Chrome: 103.0.5060.134
Safari: 15.6
npmPackages:
vite: ^3.0.4 => 3.0.4
Used Package Manager
pnpm
Logs
No response
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.