diff --git a/packages/npm-packages/ruby-3_2-wasm-wasi/src/browser.script.js b/packages/npm-packages/ruby-3_2-wasm-wasi/src/browser.script.js index 0a9592804a..9c7dcbadfc 100644 --- a/packages/npm-packages/ruby-3_2-wasm-wasi/src/browser.script.js +++ b/packages/npm-packages/ruby-3_2-wasm-wasi/src/browser.script.js @@ -1,4 +1,12 @@ import { main } from "@ruby/wasm-wasi/dist/browser.script" import * as pkg from "../package.json" -main(pkg) +main(pkg, { + env: { + // WORKAROUND(katei): setjmp consumes a LOT of stack in Ruby 3.2, + // so we extend default Fiber stack size as well as main stack + // size allocated by wasm-ld's --stack-size. 8MB is enough for + // most cases. See https://github.com/ruby/ruby.wasm/issues/273 + "RUBY_FIBER_MACHINE_STACK_SIZE": "8388608" + } +}) diff --git a/packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts b/packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts index 65d6364810..8c00940522 100644 --- a/packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts +++ b/packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts @@ -1,11 +1,14 @@ import { DefaultRubyVM } from "./browser"; -export const main = async (pkg: { name: string; version: string }) => { +export const main = async ( + pkg: { name: string; version: string }, + options?: Parameters[1], +) => { const response = fetch( `https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`, ); const module = await compileWebAssemblyModule(response); - const { vm } = await DefaultRubyVM(module); + const { vm } = await DefaultRubyVM(module, options); vm.printVersion();