{"record":{"id":"6200e41cfafa4480","repo":"dotnet/runtime","slug":"this-browser-doesn-t-support-websocket-api-please-6200e4","errorCode":null,"errorMessage":"This browser doesn't support WebSocket API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms","messagePattern":"This browser doesn't support WebSocket API\\. Please use a modern browser\\. See also https://learn\\.microsoft\\.com/aspnet/core/blazor/supported-platforms","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/web-socket.ts","lineNumber":500,"sourceCode":"function resolvedPromise(): Promise<void> | null {\n    // signal that we are finished synchronously\n    // this is optimization, which doesn't allocate and doesn't require to marshal resolve() call to C# side.\n    return null;\n}\n\nfunction rejectedPromise(message: string): Promise<any> | null {\n    const resolved = Promise.reject(new Error(message));\n    return wrapAsCancelable<void>(resolved);\n}\n\nfunction verifyEnvironment() {\n    if (ENVIRONMENT_IS_SHELL) {\n        throw new Error(\"WebSockets are not supported in shell JS engine.\");\n    }\n    if (typeof globalThis.WebSocket !== \"function\") {\n        const message = ENVIRONMENT_IS_NODE\n            ? \"Please install `ws` npm package to enable networking support.\"\n            : \"This browser doesn't support WebSocket API. Please use a modern browser. See also https://learn.microsoft.com/aspnet/core/blazor/supported-platforms\";\n        throw new Error(message);\n    }\n}\n","sourceCodeStart":482,"sourceCodeEnd":504,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/web-socket.ts#L482-L504","documentation":"Thrown by verifyEnvironment in a browser-like environment (not Node, not shell) where globalThis.WebSocket is not a function. The runtime requires the standard WebSocket API; older or non-conforming browsers are rejected up front with a link to the supported-platforms doc.","triggerScenarios":"Loading a Blazor/.NET WASM app in an old browser (legacy IE, very old Safari/Android WebView, or a locked-down embedded webview) that lacks the WebSocket constructor.","commonSituations":"Corporate legacy-browser baselines; embedded device WebViews stripped of WebSocket support; testing in a headless environment that is neither detected as Node nor has WebSocket (some custom harnesses).","solutions":["Upgrade to a supported modern browser (see https://learn.microsoft.com/aspnet/core/blazor/supported-platforms).","Add a WebSocket polyfill and assign it to globalThis.WebSocket before app startup.","If WebSockets are unavailable, configure a fallback transport (long polling / signalr server-sent events) on the server side."],"exampleFix":"// before: app starts in an old browser\nawait app.start(); // throws verifyEnvironment\n\n// after: polyfill before start\nglobalThis.WebSocket = require('websocket-polyfill').WebSocket;\nawait app.start();","handlingStrategy":"validation","validationCode":"function ensureWebSocket() {\n    if (typeof globalThis.WebSocket !== \"function\") {\n        try { globalThis.WebSocket = require(\"websocket-polyfill\").WebSocket; }\n        catch { throw new Error(\"WebSocket unsupported; upgrade browser or add polyfill\"); }\n    }\n}","typeGuard":"const browserSupportsWebSocket = (): boolean => typeof globalThis.WebSocket === \"function\";","tryCatchPattern":null,"preventionTips":["Feature-detect WebSocket before app startup and show an upgrade message if absent.","Load a polyfill for legacy browsers, or use a server-side fallback transport.","Track the Blazor supported-platforms matrix for minimum browser versions."],"tags":["websocket","browser","environment","compatibility","network"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}