dotnet/runtime · critical · Error

No fetch implementation available

Error message

No fetch implementation available

What it means

Thrown by fetch_like as the final fallthrough when none of the available code paths apply: the environment is not Node, globalThis.fetch is not a function, and the V8 shell `read` function is not available. It means there is no mechanism to load a URL at all.

Source

Thrown at src/mono/browser/runtime/loader/polyfills.ts:179

            url,
            status: 500,
            headers: {
                length: 0,
                get: () => null
            },
            statusText: "ERR28: " + e,
            arrayBuffer: () => {
                throw e;
            },
            json: () => {
                throw e;
            },
            text: () => {
                throw e;
            }
        };
    }
    throw new Error("No fetch implementation available");
}

// context: the loadBootResource extension point can return URL/string which is unqualified.
// For example `xxx/a.js` and we have to make it absolute
// For compatibility reasons, it's based of document.baseURI even for JS modules like `./xxx/a.js`, which normally use script directory of a caller of `import`
// Script directory in general doesn't match document.baseURI
export function makeURLAbsoluteWithApplicationBase (url: string) {
    mono_assert(typeof url === "string", "url must be a string");
    if (!isPathAbsolute(url) && url.indexOf("./") !== 0 && url.indexOf("../") !== 0 && globalThis.URL && globalThis.document && globalThis.document.baseURI) {
        url = (new URL(url, globalThis.document.baseURI)).toString();
    }
    return url;
}

function normalizeFileUrl (filename: string) {
    // unix vs windows
    // remove query string
    return filename.replace(/\\/g, "/").replace(/[?#].*/, "");

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Ensure the host environment provides globalThis.fetch (modern browser or Node 18+).
  2. If in a shell/sandbox, provide a global `read` function compatible with the V8 shell signature, or a fetch polyfill on globalThis.
  3. Set a custom loaderHelpers.fetch_like implementation before booting the runtime.
  4. Verify environment detection flags (ENVIRONMENT_IS_NODE etc.) are set correctly for your host.

Example fix

// before: booting in a sandbox with no fetch and no read()
// await createDotnetRuntime(opts); // throws 'No fetch implementation available'

// after: install a fetch polyfill before boot
globalThis.fetch = myFetchImpl; // e.g. unfetch or a host-specific fetch
await createDotnetRuntime(opts);
Defensive patterns

Strategy: validation

Validate before calling

function hasFetchOrRead() {
  return typeof globalThis.fetch === 'function' || typeof (globalThis as any).read === 'function';
}
if (!hasFetchOrRead()) { /* install fetch polyfill before boot */ }

Type guard

function canFetch(): boolean {
  return typeof globalThis.fetch === 'function' || typeof (globalThis as any).read === 'function';
}

Prevention

When it happens

Trigger: Produced when fetch_like cannot satisfy a request: not Node (so no fs), not a browser/Node-with-fetch, and not a V8 shell with read().

Common situations: Running in a minimal JS engine or sandbox that lacks both fetch and the read() global; a misconfigured environment detection (ENVIRONMENT_IS_NODE/_SHELL/_WEB all false) leaving no supported path.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/2f6515a452b91ca3. Report an issue: GitHub.