Skip to content

Commit

Permalink
fix: call worker unref instead of terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb committed Jun 8, 2023
1 parent 18b0599 commit 574c4cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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;
}

0 comments on commit 574c4cd

Please sign in to comment.