Skip to content

Commit 662d29d

Browse files
Map proc_exit to process exit on Node.js
1 parent 5894a86 commit 662d29d

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

Sources/CartonKit/Server/StaticArchive.swift

Lines changed: 9 additions & 9 deletions
Large diffs are not rendered by default.

entrypoint/common.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ export const WasmRunner = (rawOptions: Options | false, SwiftRuntime: SwiftRunti
6363
}
6464

6565
if (extraWasmImports) {
66-
// Shallow clone
67-
for (const key in extraWasmImports) {
68-
importObject[key] = extraWasmImports[key];
66+
for (const moduleName in extraWasmImports) {
67+
// importObject[moduleName] = extraWasmImports[moduleName];
68+
if (!importObject[moduleName]) {
69+
importObject[moduleName] = {};
70+
}
71+
for (const entry in extraWasmImports[moduleName]) {
72+
importObject[moduleName][entry] = extraWasmImports[moduleName][entry];
73+
}
6974
}
7075
}
7176

entrypoint/testNode.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ const startWasiTask = async () => {
4646

4747
const wasmRunner = WasmRunner({ args: testArgs }, runtimeConstructor);
4848

49-
await wasmRunner.run(wasmBytes);
49+
await wasmRunner.run(wasmBytes, {
50+
"wasi_snapshot_preview1": {
51+
// @bjorn3/browser_wasi_shim raises an exception when
52+
// the process exits, but we just want to exit the process itself.
53+
proc_exit: (code: number) => {
54+
process.exit(code);
55+
},
56+
}
57+
});
5058
};
5159

5260
startWasiTask().catch((e) => {

0 commit comments

Comments
 (0)