Skip to content

Commit f6947d9

Browse files
author
Guy Bedford
authored
fix: Weval stack overflow bug (#1135)
1 parent 9161deb commit f6947d9

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/compileApplicationToWasm.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dirname, resolve, sep, normalize } from 'node:path';
2-
import { tmpdir } from 'node:os';
2+
import { tmpdir, freemem } from 'node:os';
33
import { spawnSync } from 'node:child_process';
44
import { mkdir, readFile, mkdtemp, writeFile } from 'node:fs/promises';
55
import { rmSync } from 'node:fs';
@@ -131,6 +131,7 @@ export async function compileApplicationToWasm(
131131
ENABLE_EXPERIMENTAL_HIGH_RESOLUTION_TIME_METHODS:
132132
enableExperimentalHighResolutionTimeMethods ? '1' : '0',
133133
ENABLE_EXPERIMENTAL_HTTP_CACHE: enableHttpCache ? '1' : '0',
134+
RUST_MIN_STACK: Math.max(8 * 1024 * 1024, Math.floor(freemem() * 0.1)),
134135
},
135136
};
136137

@@ -144,6 +145,7 @@ export async function compileApplicationToWasm(
144145
`"${wevalBin}"`,
145146
[
146147
'weval',
148+
'-v',
147149
...(aotCache ? [`--cache-ro ${aotCache}`] : []),
148150
`--dir="${maybeWindowsPath(process.cwd())}"`,
149151
'-w',
@@ -184,6 +186,7 @@ export async function compileApplicationToWasm(
184186
`"${wevalBin}"`,
185187
[
186188
'weval',
189+
'-v',
187190
...(aotCache ? [`--cache-ro ${aotCache}`] : []),
188191
'--dir .',
189192
`--dir ${maybeWindowsPath(dirname(input))}`,
@@ -219,11 +222,9 @@ export async function compileApplicationToWasm(
219222
}
220223
}
221224
} catch (error) {
222-
console.error(
223-
`Error: Failed to compile JavaScript to Wasm: `,
224-
error.message,
225+
throw new Error(
226+
`Error: Failed to compile JavaScript to Wasm:\n${error.message}`,
225227
);
226-
process.exit(1);
227228
} finally {
228229
if (doBundle) {
229230
rmSync(tmpDir, { recursive: true });

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference path="acl.d.ts" />
12
/// <reference path="backend.d.ts" />
23
/// <reference path="body.d.ts" />
34
/// <reference path="cache-override.d.ts" />

0 commit comments

Comments
 (0)