From d7ba3bff95d701a27dbf721b570bd8a812228d6b Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Wed, 13 Dec 2023 12:50:21 +0700 Subject: [PATCH] fix: call worker `unref` instead of `terminate` (#10120) --- .changeset/moody-hornets-own.md | 5 +++++ packages/kit/src/utils/fork.js | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 .changeset/moody-hornets-own.md diff --git a/.changeset/moody-hornets-own.md b/.changeset/moody-hornets-own.md new file mode 100644 index 000000000000..7a83f6a7e18e --- /dev/null +++ b/.changeset/moody-hornets-own.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: call worker `unref` instead of `terminate` diff --git a/packages/kit/src/utils/fork.js b/packages/kit/src/utils/fork.js index cbf24ac1ba6e..96d513a21e6f 100644 --- a/packages/kit/src/utils/fork.js +++ b/packages/kit/src/utils/fork.js @@ -32,7 +32,7 @@ export function forked(module, callback) { * @param {T} opts * @returns {Promise} */ - const fn = function (opts) { + return function (opts) { return new Promise((fulfil, reject) => { const worker = new Worker(fileURLToPath(module), { env: { @@ -53,7 +53,7 @@ export function forked(module, callback) { } if (data?.type === 'result' && data.module === module) { - worker.terminate(); + worker.unref(); fulfil(data.payload); } } @@ -66,6 +66,4 @@ export function forked(module, callback) { }); }); }; - - return fn; }