diff --git a/web-spawn/js/spawn.js b/web-spawn/js/spawn.js index f1c3694..1dd9215 100644 --- a/web-spawn/js/spawn.js +++ b/web-spawn/js/spawn.js @@ -37,6 +37,11 @@ registerMessageListener(self, 'web_spawn_start_worker', async (data) => { pkg.web_spawn_start_worker(workerPtr); + // Optional hook – only call if provided by the wasm module. + if (typeof exports.__worker_teardown === 'function') { + exports.__worker_teardown(); + } + exports.__wbindgen_thread_destroy(); close(); diff --git a/web-spawn/js/spawn.no-bundler.js b/web-spawn/js/spawn.no-bundler.js index 9d031f0..fdda259 100644 --- a/web-spawn/js/spawn.no-bundler.js +++ b/web-spawn/js/spawn.no-bundler.js @@ -33,6 +33,11 @@ registerMessageListener(self, 'web_spawn_start_worker', async (data) => { const exports = wasm.initSync({ module, memory }); wasm.web_spawn_start_worker(worker); + // Optional hook – only call if provided by the wasm module. + if (typeof exports.__worker_teardown === 'function') { + exports.__worker_teardown(); + } + exports.__wbindgen_thread_destroy(); close();