-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
@rollup/plugin-terser hangs the process forever after completion when rollup is run in a worker thread #1482
Comments
This change in the repro code allows the main thread to exit: diff --git a/tools/build-worker.js b/tools/build-worker.js
index 106f78b..40e654d 100644
--- a/tools/build-worker.js
+++ b/tools/build-worker.js
@@ -6,6 +6,7 @@ const promise = new Promise(resolve => {
);
worker.on("message", () => {
+ worker.unref(); // or worker.terminate();
resolve();
});
}); |
Interesting, thanks! Do you know why that's required with @rollup/plugin-terser v0.4, but not with v0.3? Like is it a bug in v0.4, or was I somehow only getting lucky that it worked in v0.3 in the first place? I've used worker threads a few times and hadn't previously come across this issue, so it feels a little strange if sometimes I need to unref to get the process to end, but other times I don't. |
Yes, it's not returning early here: plugins/packages/terser/src/worker.ts Lines 25 to 27 in 8319720
I'll create a PR. |
PR created at #1483. |
Expected Behavior
When the build completes, the process should terminate, even if rollup is being run inside a Node.js worker thread.
Actual Behavior
When using @rollup/plugin-terser 0.4.x and running rollup inside a Node.js worker thread, the build does complete successfully, but the Node.js process never terminates.
Prior versions of @rollup/plugin-terser such as 0.3.0 did not have this problem, and running the same rollup build in the main process (rather than using a worker thread) also works fine even with @rollup/plugin-terser 0.4.x.
Additional Information
This is very likely related to #1409 since that was the only PR merged between versions 0.3.0 and 0.4.0, and it's also related to worker threads.
The text was updated successfully, but these errors were encountered: