Skip to content
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

fix: call worker unref instead of terminate #10120

Merged
merged 1 commit into from Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/moody-hornets-own.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: call worker `unref` instead of `terminate`
6 changes: 2 additions & 4 deletions packages/kit/src/utils/fork.js
Expand Up @@ -32,7 +32,7 @@ export function forked(module, callback) {
* @param {T} opts
* @returns {Promise<U>}
*/
const fn = function (opts) {
return function (opts) {
return new Promise((fulfil, reject) => {
const worker = new Worker(fileURLToPath(module), {
env: {
Expand All @@ -53,7 +53,7 @@ export function forked(module, callback) {
}

if (data?.type === 'result' && data.module === module) {
worker.terminate();
worker.unref();
fulfil(data.payload);
}
}
Expand All @@ -66,6 +66,4 @@ export function forked(module, callback) {
});
});
};

return fn;
}