dotnet/runtime · error · Error

This browser doesn't support fetch API. Please use a modern

Error message

This browser doesn't support fetch API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms

What it means

Thrown by verifyEnvironment() in http.ts when NOT on Node (i.e. a browser/shell) and globalThis.fetch or globalThis.AbortController is missing. It indicates the host browser is too old to support the Fetch API, which the .NET WASM HttpClient depends on.

Source

Thrown at src/mono/browser/runtime/http.ts:20

// The .NET Foundation licenses this file to you under the MIT license.

import BuildConfiguration from "consts:configuration";

import { wrap_as_cancelable_promise } from "./cancelable-promise";
import { ENVIRONMENT_IS_NODE, loaderHelpers, mono_assert } from "./globals";
import { assert_js_interop } from "./invoke-js";
import { MemoryViewType, Span } from "./marshal";
import type { VoidPtr } from "./types/emscripten";
import { ControllablePromise } from "./types/internal";
import { mono_log_debug } from "./logging";


function verifyEnvironment () {
    if (typeof globalThis.fetch !== "function" || typeof globalThis.AbortController !== "function") {
        const message = ENVIRONMENT_IS_NODE
            ? "Please install `node-fetch` and `node-abort-controller` npm packages to enable HTTP client support."
            : "This browser doesn't support fetch API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms";
        throw new Error(message);
    }
}

function commonAsserts (controller: HttpController) {
    assert_js_interop();
    mono_assert(controller, "expected controller");
}

export function http_wasm_supports_streaming_request (): boolean {
    // Detecting streaming request support works like this:
    // If the browser doesn't support a particular body type, it calls toString() on the object and uses the result as the body.
    // So, if the browser doesn't support request streams, the request body becomes the string "[object ReadableStream]".
    // When a string is used as a body, it conveniently sets the Content-Type header to text/plain;charset=UTF-8.
    // So, if that header is set, then we know the browser doesn't support streams in request objects, and we can exit early.
    // Safari does support streams in request objects, but doesn't allow them to be used with fetch, so the duplex option is tested, which Safari doesn't currently support.
    // See https://developer.chrome.com/articles/fetch-streaming-requests/
    if (typeof Request !== "undefined" && "body" in Request.prototype && typeof ReadableStream === "function" && typeof TransformStream === "function") {
        let duplexAccessed = false;

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Target a modern, supported browser (see the linked Blazor supported-platforms doc).
  2. Update the embedded WebView/Shell to a version with fetch and AbortController.
  3. If you must support an old browser, provide a fetch polyfill (e.g. whatwg-fetch) and an AbortController polyfill on globalThis before booting the runtime.

Example fix

// before: booting in an old WebView
// createDotnetRuntime(opts) // throws on HttpClient use

// after: polyfill fetch/AbortController in legacy WebView before boot
import 'whatwg-fetch';
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
await createDotnetRuntime(opts);
Defensive patterns

Strategy: validation

Validate before calling

function browserHttpReady() {
  return typeof globalThis.fetch === 'function' && typeof globalThis.AbortController === 'function';
}
if (!browserHttpReady()) {
  // polyfill or block the feature
}

Type guard

function supportsFetch(): boolean {
  return typeof globalThis.fetch === 'function' && typeof globalThis.AbortController === 'function';
}

Prevention

When it happens

Trigger: Produced when http_wasm_create_controller or http_wasm_fetch runs in a non-Node environment that lacks fetch or AbortController.

Common situations: Targeting very old browsers (old Safari, legacy Edge, embedded WebViews) that predate fetch support; running in a shell host (e.g. a JS engine without Web APIs) that the runtime nonetheless detects as non-Node.

Related errors


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