fetch globals are not available
I see in the tests that the global Request/Response/Headers objects are available, and I can create Headers successfully. But if I try to create Request or Response using the example, the module errors out with wasm 'unreachable' instruction executed:
diff --git a/example/hello.js b/example/hello.js
index 8671f41..fde2ac6 100644
--- a/example/hello.js
+++ b/example/hello.js
@@ -1,3 +1,11 @@
export function hello (name) {
+ // const headers = new Headers();
+
+ const req = new Request('http://httpstat.us/200', {
+ method: 'GET',
+ });
+
+ // const res = new Response();
+
return `Hello ${name}`;
}
If I return Reflect.ownKeys(globalThis).join(',') from the function, I can see also see they're on the object. My end goal is to be able to run Hono inside the module, and it uses the native req/res objects. What am I missing?
Yes, this is a duplicate of https://github.com/bytecodealliance/ComponentizeJS/issues/96, which has root cause https://github.com/bytecodealliance/StarlingMonkey/issues/19.
It's not being actively worked on because the StarlingMonkey consumers all have a custom implementation, which is very unfortunate for adoption I know!
I am, slowly, working on the upstream bug, fwiw. It's a surprisingly big change to make fetch work properly, but it is coming ☺️
Fixed in https://github.com/bytecodealliance/ComponentizeJS/pull/131.