dotnet/runtime · error · Error
Missing window to the query parameters from
Error message
Missing window to the query parameters from
What it means
withApplicationArgumentsFromQuery() on HostBuilder requires globalThis.window (i.e. a browser) because it reads location.search. If window is undefined (Node.js, shell, worker without window) it throws this. The message itself is awkwardly worded ('Missing window to the query parameters from').
Source
Thrown at src/native/libs/Common/JavaScript/loader/host-builder.ts:71
diagnosticTracing: enabled
});
return this;
}
withDebugging(level: number): DotnetHostBuilder {
mergeLoaderConfig({
debugLevel: level
});
return this;
}
withMainAssembly(mainAssemblyName: string): DotnetHostBuilder {
mergeLoaderConfig({
mainAssemblyName: mainAssemblyName
});
return this;
}
withApplicationArgumentsFromQuery(): DotnetHostBuilder {
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);
}
withApplicationEnvironment(applicationEnvironment?: string): DotnetHostBuilder {
mergeLoaderConfig({
applicationEnvironment: applicationEnvironment
});
return this;
}
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder {
mergeLoaderConfig({View on GitHub (pinned to 290d5ab72c)
Solutions
- Only call withApplicationArgumentsFromQuery() in a browser environment; gate it on typeof globalThis.window !== 'undefined'.
- In Node/shell, pass arguments explicitly via withApplicationArguments(...args) instead.
- Move the call behind an environment check (ENVIRONMENT_IS_WEB) in your bootstrap.
Example fix
// before
builder.withApplicationArgumentsFromQuery();
// after
if (typeof globalThis.window !== 'undefined') {
builder.withApplicationArgumentsFromQuery();
} else {
builder.withApplicationArguments('--arg1', '--arg2');
} Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof globalThis.window === 'undefined') {
throw new Error('withApplicationArgumentsFromQuery() requires a browser — pass args via withApplicationArguments()');
} Type guard
function isBrowserWithWindow(g: any): g is { window: Window } {
return typeof g?.window !== 'undefined';
} Prevention
- Gate browser-only calls behind ENVIRONMENT_IS_WEB or a window check.
- Keep a single bootstrap entry point per environment.
- Write a unit test that boots under Node to catch environment mismatches early.
When it happens
Trigger: Calling dotnet.withApplicationArgumentsFromQuery() in a non-browser host: Node.js, a Web Worker without DOM, or the JS shell. The guard fires before any URL parsing.
Common situations: Reusing the same bootstrap code in Node and browser; running Blazor/.NET-wasm tests under Node; SSR/prerendering harness invoking the loader; migrating from browser to worker without removing the call.
Related errors
- URLSearchParams is supported
- Missing window to the query parameters from
- URLSearchParams is supported
- Please install `node-fetch` and `node-abort-controller` npm
- This browser doesn't support fetch API. Please use a modern
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/efc6b5bb160c6b38.
Report an issue: GitHub.