{"record":{"id":"3e6570b7bc6b03df","repo":"denoland/deno","slug":"notification-requestpermission-not-supported-by-t","errorCode":null,"errorMessage":"Notification.requestPermission: not supported by this platform/backend","messagePattern":"Notification\\.requestPermission: not supported by this platform/backend","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"warning","filePath":"cli/rt/desktop.rs","lineNumber":575,"sourceCode":"        get() { return cachedNotificationPermission; },\n        enumerable: true,\n        configurable: true,\n      },\n      maxActions: internals.core.propReadOnly(0),\n      requestPermission: internals.core.propWritable(function requestPermission(\n        cb,\n      ) {\n        // The Web Notifications spec gates `requestPermission` on a\n        // transient user activation. The desktop runtime can't observe\n        // renderer activations cleanly (the OS-level UN dialog lives\n        // outside Chromium's activation tracking), so we don't enforce.\n        const promise = (async () => {\n          const s = await op_desktop_request_notification_permission();\n          if (s === \"unsupported\") {\n            // Honest signaling: this OS / backend has no notification\n            // permission model. Throw rather than silently returning a\n            // misleading \"denied\" or \"granted\".\n            throw new TypeError(\n              \"Notification.requestPermission: not supported by this platform/backend\",\n            );\n          }\n          const perm = laufeyToNotificationPermission(s);\n          cachedNotificationPermission = perm;\n          return perm;\n        })();\n        if (typeof cb === \"function\") {\n          // Deprecated callback form. Per spec, the callback is invoked\n          // with the resolved permission *and* the promise still resolves.\n          promise.then(\n            (perm) => { try { cb(perm); } catch (_) {} },\n            () => { try { cb(\"denied\"); } catch (_) {} },\n          );\n        }\n        return promise;\n      }),\n    });","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/rt/desktop.rs#L557-L593","documentation":"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'.","triggerScenarios":"Calling Notification.requestPermission() (promise form or the deprecated callback form) on a desktop runtime OS/backend that has no notification permission model.","commonSituations":"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.","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."],"exampleFix":"// before\nconst perm = await Notification.requestPermission();\n// after\nlet perm = 'denied';\ntry {\n  perm = await Notification.requestPermission();\n} catch {\n  // platform has no notification permission model\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const perm = await Notification.requestPermission();\n} catch (err) {\n  if (err instanceof TypeError && /not supported/.test(err.message)) {\n    notificationsEnabled = false; // unsupported platform, degrade\n  } else {\n    throw err;\n  }\n}","preventionTips":["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."],"tags":["notification","permissions","desktop","platform-support"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}