dotnet/runtime · error · Error

NotImplementedException

Error message

NotImplementedException

What it means

Thrown by the synthetic Response returned by fetch_like in polyfills.ts when running under NodeJS with a file:// URL (or when globalThis.fetch is absent) and the caller invokes response.text(). The Node file-loading path only implements arrayBuffer and json; reading the body as text is intentionally unimplemented, so text() throws NotImplementedException.

Solutions

  1. Read the body via arrayBuffer() or json() instead of text() for file:// URLs.
  2. Serve the resource over http:// so fetch_like uses globalThis.fetch (Node 18+) which supports text().
  3. Preload the file content yourself and pass it via config.resources.vfs instead of fetching.

Example fix

// before: text() on a file:// Response under Node
const t = await (await fetch('file:///etc/cfg.json')).text();
// after: use json() or an http URL
const j = await (await fetch('file:///etc/cfg.json')).json();
Defensive patterns

Strategy: validation

Validate before calling

// before reading a body that may come from a file:// URL under Node
if (url.startsWith('file://') && typeof globalThis.fetch !== 'function')
    throw new Error('text() not supported on file:// under Node; use arrayBuffer()');

Try / catch

try {
  return await response.text();
} catch (e) {
  if (String(e).includes('NotImplementedException'))
    return new TextDecoder().decode(await response.arrayBuffer());
  throw e;
}

Prevention

When it happens

Trigger: A component of the runtime or user code calls response.text() on a Response returned for a file:// URL under Node; fetching a local resource via file:// and then asking for its text representation.

Common situations: Running tests under Node that fetch local config files; loading assets via file:// in SSR/desktop hosts; a library that always reads bodies as text.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/8645a89a19ce4be8. Report an issue: GitHub.

Appendix: 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 60108ba66e)