dotnet/runtime · error · Error
NotImplementedException
Error message
NotImplementedException
What it means
Thrown inside the fake Response.text() implementation of fetch_like when running under Node and loading a file:// URL. The Node file-backed response supports arrayBuffer() and json() but deliberately throws NotImplementedException for text(), because the implementors chose not to decode text for local files in that path.
Source
Thrown at src/mono/browser/runtime/loader/polyfills.ts:134
// @ts-ignore:
node_fs = await import(/*! webpackIgnore: true */"fs");
}
if (isFileUrl) {
url = node_url.fileURLToPath(url);
}
const arrayBuffer = await node_fs.promises.readFile(url);
return <Response><any>{
ok: true,
headers: {
length: 0,
get: () => null
},
url,
arrayBuffer: () => arrayBuffer,
json: () => JSON.parse(arrayBuffer),
text: () => {
throw new Error("NotImplementedException");
}
};
} else if (hasFetch) {
return globalThis.fetch(url, init || { credentials: "same-origin" });
} else if (typeof (read) === "function") {
// note that it can't open files with unicode names, like Stra<unicode char - Latin Small Letter Sharp S>e.xml
// https://bugs.chromium.org/p/v8/issues/detail?id=12541
return <Response><any>{
ok: true,
url,
headers: {
length: 0,
get: () => null
},
arrayBuffer: () => {
return new Uint8Array(read(url, "binary"));
},
json: () => {View on GitHub (pinned to 290d5ab72c)
Solutions
- Avoid calling .text() on file:// responses in Node; use .arrayBuffer() or .json() instead, then decode bytes yourself.
- Load the resource over http(s):// instead of file:// so the native fetch code path (which supports text()) is used.
- Provide a custom loaderHelpers.fetch_like that returns a Response with a working text() implementation for local files.
Example fix
// before: calling text() on a Node file:// response
// const text = await (await fetch_like('file:///app/x.json')).text();
// after: use arrayBuffer and decode, or json()
const buf = await (await fetch_like('file:///app/x.json')).arrayBuffer();
const text = new TextDecoder().decode(buf); Defensive patterns
Strategy: fallback
Validate before calling
// Probe whether the response supports text() before using it
async function safeText(resp) {
try {
return await resp.text();
} catch {
const buf = await resp.arrayBuffer();
return new TextDecoder().decode(buf);
}
} Type guard
function responseSupportsText(resp: any): boolean {
return typeof resp.text === 'function' && resp.headers?.get?.('__no_text__') !== true;
} Try / catch
try {
text = await resp.text();
} catch (e) {
if (/NotImplemented/i.test(String(e))) {
text = new TextDecoder().decode(await resp.arrayBuffer());
} else throw e;
} Prevention
- Under Node, prefer arrayBuffer()/json() over text() for file:// responses.
- Install a custom fetch_like that returns a fully-featured Response for local files.
- Load assets over http(s):// in Node to use the native fetch code path.
When it happens
Trigger: Produced when something in the runtime calls response.text() on a Response returned by fetch_like for a Node file:// resource. The response object's text() method unconditionally throws 'NotImplementedException'.
Common situations: A library or runtime subsystem that expects .text() on boot/resource responses under Node; reading a config or asset as text from the local filesystem in Node when the runtime uses the file-path code branch.
Related errors
- Please install `node-fetch` and `node-abort-controller` npm
- No fetch implementation available
- Using node without crypto support. To enable current operati
- No fetch implementation available
- Please install `node-fetch` and `node-abort-controller` npm
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/8645a89a19ce4be8.
Report an issue: GitHub.