dotnet/runtime · error · Error
Missing window to the query parameters from
Error message
Missing window to the query parameters from
What it means
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.
Source
Thrown at src/mono/browser/runtime/loader/run.ts:178
}
}
withMainAssembly (mainAssemblyName: string): DotnetHostBuilder {
try {
deep_merge_config(monoConfig, {
mainAssemblyName
});
return this;
} catch (err) {
mono_exit(1, err);
throw err;
}
}
withApplicationArgumentsFromQuery (): DotnetHostBuilder {
try {
if (!globalThis.window) {
throw new Error("Missing window to the query parameters from");
}
if (typeof globalThis.URLSearchParams == "undefined") {
throw new Error("URLSearchParams is supported");
}
const params = new URLSearchParams(globalThis.window.location.search);
const values = params.getAll("arg");
return this.withApplicationArguments(...values);
} catch (err) {
mono_exit(1, err);
throw err;
}
}
withApplicationEnvironment (applicationEnvironment?: string): DotnetHostBuilder {
try {
deep_merge_config(monoConfig, {View on GitHub (pinned to 290d5ab72c)
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(...).
Example fix
// before: unconditional
// builder.withApplicationArgumentsFromQuery();
// after: guard for browser
if (typeof globalThis !== 'undefined' && globalThis.window) {
builder.withApplicationArgumentsFromQuery();
} else {
builder.withApplicationArguments(...process.argv.slice(2));
} Defensive patterns
Strategy: validation
Validate before calling
if (typeof globalThis === 'undefined' || !globalThis.window) {
// do not call withApplicationArgumentsFromQuery here; pass args explicitly
} Type guard
function hasWindow(): boolean {
return typeof globalThis !== 'undefined' && typeof (globalThis as any).window !== 'undefined';
} Prevention
- 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.
When it happens
Trigger: Produced when calling .withApplicationArgumentsFromQuery() in a non-browser context: Node, a Web Worker, or a shell environment where globalThis.window does not exist.
Common situations: 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.
Related errors
- NodeJS at '${process.execPath}' has too low version '${proce
- URLSearchParams is supported
- Missing window to the query parameters from
- Please install `node-fetch` and `node-abort-controller` npm
- Unexpected behavior ${asset.behavior} of asset ${asset.name}
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/c8af9cb8c0aee91d.
Report an issue: GitHub.