{"record":{"id":"c8af9cb8c0aee91d","repo":"dotnet/runtime","slug":"missing-window-to-the-query-parameters-from","errorCode":null,"errorMessage":"Missing window to the query parameters from","messagePattern":"Missing window to the query parameters from","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/loader/run.ts","lineNumber":178,"sourceCode":"        }\n    }\n\n    withMainAssembly (mainAssemblyName: string): DotnetHostBuilder {\n        try {\n            deep_merge_config(monoConfig, {\n                mainAssemblyName\n            });\n            return this;\n        } catch (err) {\n            mono_exit(1, err);\n            throw err;\n        }\n    }\n\n    withApplicationArgumentsFromQuery (): DotnetHostBuilder {\n        try {\n            if (!globalThis.window) {\n                throw new Error(\"Missing window to the query parameters from\");\n            }\n\n            if (typeof globalThis.URLSearchParams == \"undefined\") {\n                throw new Error(\"URLSearchParams is supported\");\n            }\n\n            const params = new URLSearchParams(globalThis.window.location.search);\n            const values = params.getAll(\"arg\");\n            return this.withApplicationArguments(...values);\n        } catch (err) {\n            mono_exit(1, err);\n            throw err;\n        }\n    }\n\n    withApplicationEnvironment (applicationEnvironment?: string): DotnetHostBuilder {\n        try {\n            deep_merge_config(monoConfig, {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/loader/run.ts#L160-L196","documentation":"Thrown by HostBuilder.withApplicationArgumentsFromQuery when globalThis.window is undefined. The method reads query parameters from window.location.search, so it can only run in a browser main thread with a DOM window.","triggerScenarios":"Produced when calling .withApplicationArgumentsFromQuery() in a non-browser context: Node, a Web Worker, or a shell environment where globalThis.window does not exist.","commonSituations":"Using the same HostBuilder setup code for both browser and Node/worker; calling this builder method inside a Web Worker boot path; running under NodeJS tests.","solutions":["Only call withApplicationArgumentsFromQuery() in a browser main-thread boot path.","Branch your boot code on environment (e.g. if (globalThis.window) builder.withApplicationArgumentsFromQuery()).","In non-browser hosts, pass arguments explicitly via withApplicationArguments(...)."],"exampleFix":"// before: unconditional\n// builder.withApplicationArgumentsFromQuery();\n\n// after: guard for browser\nif (typeof globalThis !== 'undefined' && globalThis.window) {\n  builder.withApplicationArgumentsFromQuery();\n} else {\n  builder.withApplicationArguments(...process.argv.slice(2));\n}","handlingStrategy":"validation","validationCode":"if (typeof globalThis === 'undefined' || !globalThis.window) {\n  // do not call withApplicationArgumentsFromQuery here; pass args explicitly\n}","typeGuard":"function hasWindow(): boolean {\n  return typeof globalThis !== 'undefined' && typeof (globalThis as any).window !== 'undefined';\n}","tryCatchPattern":null,"preventionTips":["Branch boot code on environment; only use the query-args builder in the browser main thread.","Pass application arguments explicitly in Node/worker hosts.","Keep a single environment-aware boot helper to avoid copy-paste mistakes."],"tags":["startup","environment","config","node","worker"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}