{"record":{"id":"808859467c8757eb","repo":"OrchardCMS/OrchardCore","slug":"could-not-find-global","errorCode":null,"errorMessage":"could not find global","messagePattern":"could not find global","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js","lineNumber":552,"sourceCode":"    }\n    return `${e}`;\n}\n/** @private */\nfunction getGlobalThis() {\n    // globalThis is semi-new and not available in Node until v12\n    if (typeof globalThis !== \"undefined\") {\n        return globalThis;\n    }\n    if (typeof self !== \"undefined\") {\n        return self;\n    }\n    if (typeof window !== \"undefined\") {\n        return window;\n    }\n    if (typeof __webpack_require__.g !== \"undefined\") {\n        return __webpack_require__.g;\n    }\n    throw new Error(\"could not find global\");\n}\n\n;// CONCATENATED MODULE: ./src/FetchHttpClient.ts\n// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\n\n\n\nclass FetchHttpClient extends HttpClient {\n    constructor(logger) {\n        super();\n        this._logger = logger;\n        // Node added a fetch implementation to the global scope starting in v18.\n        // We need to add a cookie jar in node to be able to share cookies with WebSocket\n        if (typeof fetch === \"undefined\" || Platform.isNode) {\n            // In order to ignore the dynamic require in webpack builds we need to do this magic\n            // @ts-ignore: TS doesn't know about these names","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.SignalR/wwwroot/Scripts/signalr.js#L534-L570","documentation":"The bundled SignalR client's getGlobalThis helper tries window, then the webpack global (__webpack_require__.g), and throws 'could not find global' if neither exists. The library cannot locate a global object to attach to, which is fatal at construction time (called from the constructor chain).","triggerScenarios":"Running the UMD/bundled signalr.js in an environment with no window and no webpack global — e.g. restricted JS sandbox, non-browser runtime (web worker with unusual globals, server-side execution of the browser bundle), or a bundler stripping the global shim.","commonSituations":"Executing the browser bundle under Node/SSR instead of the node package, exotic embedded JS engines, CSP/sandboxed iframes lacking expected globals.","solutions":["Load the correct signalr build for your environment (browser bundle in browsers, node build in Node)","Ensure window (or the webpack global object) exists before the script runs","Run the script after DOM/environment setup, not in a pre-global sandbox"],"exampleFix":"// before\nimport signalr from './wwwroot/Scripts/signalr.js' // browser bundle, SSR context\n// after\nimport * as signalr from '@microsoft/signalr' // environment-appropriate build","handlingStrategy":"fallback","validationCode":"const hasGlobal = typeof window !== 'undefined' || typeof globalThis !== 'undefined'; if (!hasGlobal) throw new Error('signalr browser bundle requires a global object');","typeGuard":"const inBrowser = () => typeof window !== 'undefined' && typeof window.document !== 'undefined';","tryCatchPattern":"try { initSignalR(); } catch (e) { if (e.message === 'could not find global') { console.error('Wrong signalr bundle for this environment'); loadNodeBuildFallback(); } }","preventionTips":["Match the signalr bundle to the runtime environment","Avoid running browser bundles in Node/SSR/workers","Smoke-test script loading in every deployment target"],"tags":["javascript","signalr","environment","global-object"],"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"}