Skip to content

Commit 6349e3e

Browse files
feat: allow setting rust min stack size
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent c4d72cd commit 6349e3e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/componentize.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ function maybeWindowsPath(path) {
3232
return '//?/' + resolve(path).replace(/\\/g, '/');
3333
}
3434

35+
/**
36+
* Check whether a value is numeric (including BigInt)
37+
*
38+
* @param {any} n
39+
* @returns {boolean} whether the value is numeric
40+
*/
41+
function isNumeric(n) {
42+
switch (typeof n) {
43+
case "bigint":
44+
case "number":
45+
return true;
46+
case "object":
47+
return n.constructor == BigInt || n.constructor == Number;
48+
default:
49+
return false;
50+
}
51+
}
52+
3553
export async function componentize(jsSource, witWorld, opts) {
3654
if (typeof witWorld === 'object') {
3755
opts = witWorld;
@@ -236,6 +254,14 @@ export async function componentize(jsSource, witWorld, opts) {
236254
wevalBin = await getWeval();
237255
}
238256

257+
// Set the min stack size, if one was provided
258+
if (opts.aotMinStackSizeBytes) {
259+
if (!isNumeric(opts.aotMinStackSizeBytes)) {
260+
throw new TypeError(`aotMinStackSizeBytes must be a numeric value, received [${opts.aotMinStackSizeBytes}] (type ${typeof opts.aotMinStackSizeBytes})`);
261+
}
262+
env.RUST_MIN_STACK = opts.aotMinStackSizeBytes;
263+
}
264+
239265
try {
240266
let wevalProcess = spawnSync(
241267
wevalBin,

0 commit comments

Comments
 (0)