-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
I tried the example code on the website. I tried Node 18.x, 20.x, 22.x, they all say "TypeError": fetch failed" and "Error: not implemented... yet..."
For reference, here is the code I'm talking about, it fails at very next line from importinging, await.init()...
import { init, Wasmer } from "@wasmer/sdk";
await init();
const pkg = await Wasmer.fromRegistry("python/python");
const instance = await pkg.entrypoint.run({
args: ["-c", "print('Hello, World!')"],
});
const { code, stdout } = await instance.wait();
console.log(`Python exited with ${code}: ${stdout}`);
Here is the error...
node:internal/deps/undici/undici:13185
Error.captureStackTrace(err);
^
TypeError: fetch failed at node:internal/deps/undici/undici:13185:13 at async v_ (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:47648)
at async R_ (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:48139)
at async file:///C:/code/onexdata/wasm/wasmer/node-server/example.js:3:1 {
[cause]: Error: not implemented... yet...
at makeNetworkError (node:internal/deps/undici/undici:8968:35)
at schemeFetch (node:internal/deps/undici/undici:10363:34)
at node:internal/deps/undici/undici:10212:26
at mainFetch (node:internal/deps/undici/undici:10231:11)
at fetching (node:internal/deps/undici/undici:10179:7)
at fetch (node:internal/deps/undici/undici:10048:20)
at fetch (node:internal/deps/undici/undici:13183:10)
at fetch (node:internal/bootstrap/web/exposed-window-or-worker:72:12)
at v_ (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:46947)
at R_ (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:48145)
}
Node.js v20.18.0
When I rewrite everything and use a polyfill for fetch, I produce this...
import { init, Wasmer } from "@wasmer/sdk";
import fetch from 'node-fetch';
import { createRequire } from 'module';
import { fileURLToPath } from 'url';
import fs from 'fs/promises';
const require = createRequire(import.meta.url);
// Custom fetch implementation that handles both HTTP and file protocols
global.fetch = async (urlOrRequest, options) => {
const url = urlOrRequest instanceof URL ? urlOrRequest.href : urlOrRequest.toString();
if (url.startsWith('file:')) {
const filePath = fileURLToPath(url);
const buffer = await fs.readFile(filePath);
return new Response(buffer);
}
return fetch(url, options);
};
try {
await init();
const pkg = await Wasmer.fromRegistry("python/python");
const instance = await pkg.entrypoint.run({
args: ["-c", "print('Hello, World!')"],
});
const { code, stdout } = await instance.wait();
console.log(`Python exited with ${code}: ${stdout}`);
} catch (error) {
console.error('Error:', error);
}
Which generates this error, indicating python/python doesn't actually exist, is this accurate?
`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:
TypeError [ERR_WEBASSEMBLY_RESPONSE]: WebAssembly response has unsupported MIME type 'null'
at new NodeError (node:internal/errors:405:5)
at node:internal/wasm_web_api:30:13 {
code: 'ERR_WEBASSEMBLY_RESPONSE'
}
Error: Error: Unable to find "python/python" in the registry
at e.wbg.__wbg_new_28c511d9baebfa89 (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:35384)
at wasm://wasm/015c03b2:wasm-function[1466]:0x2fbfb8
at wasm://wasm/015c03b2:wasm-function[6951]:0x4230c1
at wasm://wasm/015c03b2:wasm-function[337]:0x10a2da
at wasm://wasm/015c03b2:wasm-function[2038]:0x34ba1e
at wasm://wasm/015c03b2:wasm-function[10511]:0x449902
at wasm://wasm/015c03b2:wasm-function[9401]:0x44074e
at v (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:2534)
at o (file:///C:/code/onexdata/wasm/wasmer/node-server/node_modules/@wasmer/sdk/dist/index.mjs:11:2374) {
detailedMessage: 'Unable to find "python/python" in the registry\n' +
'\n' +
'Caused by:\n' +
" 0: failed to query package 'python/python': Could not fetch 'https://registry.wasmer.io/graphql'\n" +
" 1: Could not fetch 'https://registry.wasmer.io/graphql'\n" +
' 2: Invalid URL',
causes: [
"failed to query package 'python/python': Could not fetch 'https://registry.wasmer.io/graphql'",
"Could not fetch 'https://registry.wasmer.io/graphql'",
'Invalid URL'
]
}
lancetiptongeersch
Metadata
Metadata
Assignees
Labels
No labels