{"record":{"id":"68ec73795035d064","repo":"OrchardCMS/OrchardCore","slug":"eventsource-is-not-supported-in-your-environment","errorCode":null,"errorMessage":"'EventSource' is not supported in your environment.","messagePattern":"'EventSource' is not supported in your environment\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js","lineNumber":2998,"sourceCode":"                    }\n                }\n            }\n        }\n        if (transportExceptions.length > 0) {\n            return Promise.reject(new AggregateErrors(`Unable to connect to the server with any of the available transports. ${transportExceptions.join(\" \")}`, transportExceptions));\n        }\n        return Promise.reject(new Error(\"None of the transports supported by the client are supported by the server.\"));\n    }\n    _constructTransport(transport) {\n        switch (transport) {\n            case HttpTransportType.WebSockets:\n                if (!this._options.WebSocket) {\n                    throw new Error(\"'WebSocket' is not supported in your environment.\");\n                }\n                return new WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});\n            case HttpTransportType.ServerSentEvents:\n                if (!this._options.EventSource) {\n                    throw new Error(\"'EventSource' is not supported in your environment.\");\n                }\n                return new ServerSentEventsTransport(this._httpClient, this._httpClient._accessToken, this._logger, this._options);\n            case HttpTransportType.LongPolling:\n                return new LongPollingTransport(this._httpClient, this._logger, this._options);\n            default:\n                throw new Error(`Unknown transport: ${transport}.`);\n        }\n    }\n    _startTransport(url, transferFormat) {\n        this.transport.onreceive = this.onreceive;\n        if (this.features.reconnect) {\n            this.transport.onclose = async (e) => {\n                let callStop = false;\n                if (this.features.reconnect) {\n                    try {\n                        this.features.disconnected();\n                        await this.transport.connect(url, transferFormat);\n                        await this.features.resend();","sourceCodeStart":2980,"sourceCodeEnd":3016,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js#L2980-L3016","documentation":"The SignalR JavaScript client's HttpConnection only knows how to create a transport when the runtime provides the required browser API. When the negotiated transport is ServerSentEvents but no EventSource constructor is available (either not injected via options or running in a non-browser environment without EventSource), it throws this Error.","triggerScenarios":"Calling connection.start() (or negotiateMultipleTimes selecting SSE) where HttpTransportType.ServerSentEvents is negotiated and options.EventSource is null/undefined — e.g. in Node.js, web workers, or an environment where EventSource polyfill was not supplied.","commonSituations":"Running the signalr client in Node SSR or a web worker; IE/old browsers without EventSource; forgetting to pass an EventSource polyfill in withUrl options; forcing skipNegotiation with SSE transport in unsupported environments.","solutions":["Use the WebSocket or LongPolling transport instead of ServerSentEvents (configure HttpConnectionOptions or let negotiation pick WebSocket).","In non-browser environments, provide an EventSource polyfill via options: new HubConnectionBuilder().withUrl(url, { EventSource: require('eventsource') }).","Run the client in a normal browser context where window.EventSource exists.","Check navigator/feature detection before choosing the SSE transport."],"exampleFix":"// before\nconst conn = new signalR.HubConnectionBuilder().withUrl(url, { transport: signalR.HttpTransportType.ServerSentEvents }).build();\n// after\nconst conn = new signalR.HubConnectionBuilder().withUrl(url, { transport: signalR.HttpTransportType.WebSockets }).build();\n// or in Node:\n// withUrl(url, { EventSource: require('eventsource') })","handlingStrategy":"fallback","validationCode":"// before choosing SSE\nif (typeof EventSource === 'undefined') {\n  throw new Error('EventSource unavailable: pick WebSocket/LongPolling or supply a polyfill');\n}","typeGuard":"const supportsSSE = (opts) => typeof (opts?.EventSource ?? (typeof globalThis !== 'undefined' ? globalThis.EventSource : undefined)) === 'function';","tryCatchPattern":"try {\n  await connection.start();\n} catch (e) {\n  if (String(e.message).includes(\"'EventSource' is not supported\")) {\n    // fall back to WebSockets/LongPolling transport\n  }\n}","preventionTips":["Feature-detect EventSource before selecting the SSE transport.","Supply an EventSource polyfill (e.g. 'eventsource' npm package) in Node/worker environments.","Prefer WebSocket transport; SSE is rarely needed when WebSockets are available.","Pin matching @microsoft/signalr client versions."],"tags":["signalr","javascript","eventsource","transport"],"backgroundTag":"unsupported-platform","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}