@rspack/binding-wasm32-wasi 1.4.5 → 1.4.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rspack.wasi.cjs +12 -0
- package/rspack.wasm32-wasi.wasm +0 -0
package/package.json
CHANGED
package/rspack.wasi.cjs
CHANGED
|
@@ -66,6 +66,18 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
|
|
|
66
66
|
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// We have enabled `reuseWorker` so normally the workers never exit, unless there's any exception.
|
|
70
|
+
// For Rust threads, aborting one thread means aborting the process, but actually aborting Node.js workers doesn't abort the main thread.
|
|
71
|
+
// I'm not sure whether it's the expected behavior of Node.js workers, or the behavior has been controlled by emnapi.
|
|
72
|
+
// Anyway, this code is used for fix the bug:
|
|
73
|
+
// When the main thread holds a strong tsfn that prevents the Node.js event loop exiting,
|
|
74
|
+
// if the worker responsible for unref the tsfn terminates, then the main thread will never exits.
|
|
75
|
+
worker.on('exit', (code) => {
|
|
76
|
+
if (code !== 0) {
|
|
77
|
+
process.exit(code);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
69
81
|
// The main thread of Node.js waits for all the active handles before exiting.
|
|
70
82
|
// But Rust threads are never waited without `thread::join`.
|
|
71
83
|
// So here we hack the code of Node.js to prevent the workers from being referenced (active).
|
package/rspack.wasm32-wasi.wasm
CHANGED
|
Binary file
|