From 574c4cd9c7b7341a5f40818aaa8bb42b8483ad37 Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Thu, 8 Jun 2023 21:15:55 +0700 Subject: [PATCH] fix: call worker `unref` instead of `terminate` --- .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; }