denoland/deno · error · TypeError
Failed to execute 'query' on 'Permissions': descriptor…
Error message
Failed to execute 'query' on 'Permissions': descriptor required
What it means
The desktop runtime provides a Permissions implementation whose query() supports the 'notifications' permission. Following the Permissions API, the descriptor must be a non-null object; anything else throws a TypeError with the standard "Failed to execute 'query' on 'Permissions'" prefix.
Solutions
- Pass a descriptor object: `await navigator.permissions.query({ name: "notifications" })`
- Guard the call: only invoke query when the descriptor is a non-null object with a string name
- Remember only the 'notifications' name is meaningful in this runtime
Example fix
// before
const s = await navigator.permissions.query("notifications");
// after
const s = await navigator.permissions.query({ name: "notifications" }); Defensive patterns
Strategy: type-guard
Validate before calling
if (descriptor == null || typeof descriptor !== "object") {
throw new TypeError("descriptor required");
} Type guard
function isPermissionDescriptor(d: unknown): d is { name: string } {
return typeof d === "object" && d !== null &&
typeof (d as { name?: unknown }).name === "string";
} Prevention
- Always pass a descriptor object: query({ name: 'notifications' })
- Type query inputs as PermissionDescriptor so the compiler rejects strings
- Remember only the 'notifications' name is meaningful in the desktop runtime
When it happens
Trigger: `permissions.query()` with no argument; `permissions.query(null)`; passing a bare string `permissions.query("notifications")` instead of the object `{ name: "notifications" }`.
Common situations: Refactoring from a custom permissions helper that accepted strings; copying browser code that queries multiple permissions; forgetting the descriptor wrapper in TypeScript where the type was loosened to any.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Notification.requestPermission: not supported by this…
- bundle identifier is longer than 155 characters
- bundle identifier must be in reverse-DNS form (e.g…
- bundle identifier must match [A-Za-z0-9.-]+, but contains
- bundle identifier is empty
AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20).
Data as JSON: /api/errors/cecac2e312c086c7.
Report an issue: GitHub.
Appendix: source
Thrown at cli/rt/desktop.rs:655
set onchange(v) { this.#onchange = typeof v === "function" ? v : null; }
}
function laufeyToPermissionsApiState(s) {
// Spec maps "prompt" through verbatim; "unsupported" has no spec
// analog so we return "denied" — query() shouldn't throw, but we
// shouldn't lie and say "granted" either.
switch (s) {
case "granted": return "granted";
case "denied": return "denied";
case "prompt": return "prompt";
default: return "denied";
}
}
const permissionsImpl = {
async query(descriptor) {
if (descriptor == null || typeof descriptor !== "object") {
throw new TypeError(
"Failed to execute 'query' on 'Permissions': descriptor required",
);
}
const name = String(descriptor.name);
if (name === "notifications") {
// No side effects per spec — never call request_*.
const s = await op_desktop_query_notification_permission();
// Keep Notification.permission's cache in sync: a permissions.query
// result is authoritative and lets the synchronous getter report
// a current value without us needing a second roundtrip.
if (s !== "unsupported") {
cachedNotificationPermission = laufeyToNotificationPermission(s);
}
return new PermissionStatus(name, laufeyToPermissionsApiState(s));
}
// Unknown / unrouted name. Chrome returns "denied" for descriptors
// it doesn't recognize; mimic that rather than throwing.
return new PermissionStatus(name, "denied");View on GitHub (pinned to f7822238ca)