Skip to content

Commit 16c829d

Browse files
Remove workaround for @bjorn3/browser_wasi_shim
Those issues are now fixed in the upstream `@bjorn3/browser_wasi_shim`
1 parent 8b74eb9 commit 16c829d

File tree

4 files changed

+9
-57
lines changed

4 files changed

+9
-57
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/npm-packages/ruby-wasm-wasi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"jest": "^29.6.2",
6363
"prettier": "^3.0.0",
6464
"rollup": "^4.6.1",
65-
"@bjorn3/browser_wasi_shim": "^0.2.16",
65+
"@bjorn3/browser_wasi_shim": "^0.2.17",
6666
"typescript": "^5.3.2"
6767
},
6868
"dependencies": {

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@ export const DefaultRubyVM = async (
2828
const printer = options.consolePrint ?? true ? consolePrinter() : undefined;
2929
printer?.addToImports(imports);
3030

31-
{
32-
// WORKAROUND: browser_wasi_shim does not support some syscalls yet
33-
// and returns -1 instead of proper ERRNO values and it results in confusing
34-
// error messages "Success -- /path/to/file".
35-
// Update browser_wasi_shim version when my fix[^1] will be released.
36-
// [^1]: https://github.com/bjorn3/browser_wasi_shim/commit/6193f7482633ef818604375d9755ded67946adfc
37-
const syscalls = imports["wasi_snapshot_preview1"];
38-
for (const name of Object.keys(syscalls)) {
39-
const original = syscalls[name];
40-
syscalls[name] = (...args) => {
41-
const result = original(...args);
42-
if (result === -1) {
43-
return 58; // ENOTSUP
44-
}
45-
// browser_wasi_shim's `random_get` returns `undefined` on success
46-
// instead of `0`.
47-
if (result === undefined) {
48-
return 0; // Success
49-
}
50-
return result;
51-
};
52-
}
53-
}
54-
5531
const instance = await WebAssembly.instantiate(rubyModule, imports);
5632
await vm.setInstance(instance);
5733

packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,6 @@ const instantiateWasmerWasi = async (rootTestFile) => {
131131
printer.addToImports(imports);
132132
vm.addToImports(imports);
133133

134-
{
135-
// WORKAROUND: browser_wasi_shim does not support some syscalls yet
136-
// and returns -1 instead of proper ERRNO values and it results in confusing
137-
// error messages "Success -- /path/to/file".
138-
// Update browser_wasi_shim version when my fix[^1] will be released.
139-
// [^1]: https://github.com/bjorn3/browser_wasi_shim/commit/6193f7482633ef818604375d9755ded67946adfc
140-
const syscalls = imports["wasi_snapshot_preview1"]
141-
for (const name of Object.keys(syscalls)) {
142-
const original = syscalls[name];
143-
syscalls[name] = (...args) => {
144-
const result = original(...args);
145-
if (result === -1) {
146-
return 58; // ENOTSUP
147-
}
148-
// browser_wasi_shim's `random_get` returns `undefined` on success
149-
// instead of `0`.
150-
if (result === undefined) {
151-
return 0; // Success
152-
}
153-
return result;
154-
};
155-
}
156-
}
157-
158134
const instance = await WebAssembly.instantiate(rubyModule, imports);
159135
printer.setMemory(instance.exports.memory);
160136
await vm.setInstance(instance);

0 commit comments

Comments
 (0)