Skip to content

Commit

Permalink
fix: call worker unref instead of terminate (#10120)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb authored Dec 13, 2023
1 parent 40bb1e6 commit d7ba3bf
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 d7ba3bf

Please sign in to comment.