denoland/deno · warning · TypeError
Notification.requestPermission: not supported by this platfo
Error message
Notification.requestPermission: not supported by this platform/backend
What it means
Notification.requestPermission() asks the OS/backend via op_desktop_request_notification_permission. When the backend reports 'unsupported' (this OS has no notification permission model), the wrapper throws instead of answering with a misleading 'granted' or 'denied'.
Source
Thrown at cli/rt/desktop.rs:575
get() { return cachedNotificationPermission; },
enumerable: true,
configurable: true,
},
maxActions: internals.core.propReadOnly(0),
requestPermission: internals.core.propWritable(function requestPermission(
cb,
) {
// The Web Notifications spec gates `requestPermission` on a
// transient user activation. The desktop runtime can't observe
// renderer activations cleanly (the OS-level UN dialog lives
// outside Chromium's activation tracking), so we don't enforce.
const promise = (async () => {
const s = await op_desktop_request_notification_permission();
if (s === "unsupported") {
// Honest signaling: this OS / backend has no notification
// permission model. Throw rather than silently returning a
// misleading "denied" or "granted".
throw new TypeError(
"Notification.requestPermission: not supported by this platform/backend",
);
}
const perm = laufeyToNotificationPermission(s);
cachedNotificationPermission = perm;
return perm;
})();
if (typeof cb === "function") {
// Deprecated callback form. Per spec, the callback is invoked
// with the resolved permission *and* the promise still resolves.
promise.then(
(perm) => { try { cb(perm); } catch (_) {} },
() => { try { cb("denied"); } catch (_) {} },
);
}
return promise;
}),
});View on GitHub (pinned to 89f33cbef2)
Solutions
- Wrap the call in try/catch and degrade gracefully (disable notifications).
- Feature-detect first via Notification.permission or navigator.permissions.query({ name: 'notifications' }).
- Confirm the desktop runtime backend supports notifications on the target OS.
Example fix
// before
const perm = await Notification.requestPermission();
// after
let perm = 'denied';
try {
perm = await Notification.requestPermission();
} catch {
// platform has no notification permission model
} Defensive patterns
Strategy: try-catch
Try / catch
try {
const perm = await Notification.requestPermission();
} catch (err) {
if (err instanceof TypeError && /not supported/.test(err.message)) {
notificationsEnabled = false; // unsupported platform, degrade
} else {
throw err;
}
} Prevention
- Never assume requestPermission resolves; treat an unsupported platform as a normal outcome with a disabled state.
- Centralize permission handling in one helper so the fallback path is consistent across the app.
When it happens
Trigger: Calling Notification.requestPermission() (promise form or the deprecated callback form) on a desktop runtime OS/backend that has no notification permission model.
Common situations: Running the desktop runtime on an OS without a notification permission concept, or a build whose notification backend is absent; feature-detection code that assumes the promise always resolves.
Related errors
- Failed to execute 'query' on 'Permissions': descriptor requi
- Failed to construct 'Notification': 1 argument required, but
- Unexpected 'name' field in options, bench name is already pr
- The bench function must have a name
- Unexpected second argument to Deno.bench()
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/3e6570b7bc6b03df.
Report an issue: GitHub.