Skip to content

Maximum call stack size exceeded #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
talentlessguy opened this issue Apr 27, 2025 · 0 comments
Open

Maximum call stack size exceeded #11

talentlessguy opened this issue Apr 27, 2025 · 0 comments

Comments

@talentlessguy
Copy link

This works on Node.js with node:wasi:

import { readFile } from 'node:fs/promises';
import { WASI } from 'node:wasi';
import { argv, env } from 'node:process';

const wasi = new WASI({
  version: 'preview1',
  args: [argv[1], '--help'],
  features: [],
  env,
});

const wasm = await WebAssembly.compile(
  await readFile(new URL('./dist/bee.wasm', import.meta.url)),
);
const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());

wasi.start(instance);

This doesn't work on Deno, nor Bun:

import { readFile } from 'node:fs/promises'
import { useArgs, useEnviron, useStdio, WASI } from 'npm:uwasi'
import { argv, env } from 'node:process'

const wasi = new WASI({
  version: 'preview1',
  args: [argv[1], '--help'],
  features: [useEnviron, useArgs, useStdio],
  env,
})

const wasm = await WebAssembly.compile(
  await readFile(new URL('./dist/bee.wasm', import.meta.url)),
)
const instance = await WebAssembly.instantiate(wasm, {
  wasi_snapshot_preview1: wasi.wasiImport,
})

wasi.start(instance)

The error is this:

error: Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at WASI.wasiImport.<computed> (file:///Users/user/Library/Caches/deno/npm/registry.npmjs.org/uwasi/1.4.1/lib/esm/index.js:1:1)
    at runtime.fd_write (wasm://wasm/12e425de:1:833563)
    at runtime.write1 (wasm://wasm/12e425de:1:833910)
    at runtime.write (wasm://wasm/12e425de:1:1479550)
    at runtime.writeErrData (wasm://wasm/12e425de:1:1062994)
    at runtime.badsystemstack (wasm://wasm/12e425de:1:1157894)
    at runtime.systemstack (wasm://wasm/12e425de:1:1488639)
    at runtime.throw (wasm://wasm/12e425de:1:1438248)
    at runtime.write1 (wasm://wasm/12e425de:1:834025)
    at runtime.write (wasm://wasm/12e425de:1:1479550)

if it's related to permissions (as I see fd_write) - probably it's better to output a nicer error message that makes it clear on what's wrong

@talentlessguy talentlessguy changed the title Maximum callstack exceeded Maximum call stack size exceeded Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant