Skip to content

Commit 57ccc24

Browse files
Apply larger fiber stack size workaround only to Ruby 3.2
1 parent b4590e4 commit 57ccc24

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { main } from "@ruby/wasm-wasi/dist/browser.script"
22
import * as pkg from "../package.json"
33

4-
main(pkg)
4+
main(pkg, {
5+
env: {
6+
// WORKAROUND(katei): setjmp consumes a LOT of stack in Ruby 3.2,
7+
// so we extend default Fiber stack size as well as main stack
8+
// size allocated by wasm-ld's --stack-size. 8MB is enough for
9+
// most cases. See https://github.com/ruby/ruby.wasm/issues/273
10+
"RUBY_FIBER_MACHINE_STACK_SIZE": "8388608"
11+
}
12+
})

packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { DefaultRubyVM } from "./browser";
22

3-
export const main = async (pkg: { name: string; version: string }) => {
3+
export const main = async (
4+
pkg: { name: string; version: string },
5+
options?: Parameters<typeof DefaultRubyVM>[1],
6+
) => {
47
const response = fetch(
58
`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`,
69
);
710
const module = await compileWebAssemblyModule(response);
8-
const { vm } = await DefaultRubyVM(module);
11+
const { vm } = await DefaultRubyVM(module, options);
912

1013
vm.printVersion();
1114

0 commit comments

Comments
 (0)