{"record":{"id":"440b584d7e0adc1d","repo":"denoland/deno","slug":"failed-to-construct-notification-1-argument-req","errorCode":null,"errorMessage":"Failed to construct 'Notification': 1 argument required, but only 0 present.","messagePattern":"Failed to construct 'Notification': 1 argument required, but only 0 present\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cli/rt/desktop.rs","lineNumber":498,"sourceCode":"        return out;\n      }\n      return new TextEncoder().encode(decodeURIComponent(payload));\n    } catch {\n      return null;\n    }\n  }\n\n  const NotificationPrototype = NotificationNative.prototype;\n  Object.setPrototypeOf(NotificationPrototype, EventTarget.prototype);\n\n  const notifications = new Map();\n  // The Web Notifications API constructor is `new Notification(title, options?)`\n  // and shows the notification immediately. The native constructor takes\n  // a third arg for pre-decoded icon bytes so the icon URL → bytes step\n  // happens on the JS side (sync data: URL decoding only).\n  const Notification = function Notification(title, options) {\n    if (arguments.length < 1) {\n      throw new TypeError(\n        \"Failed to construct 'Notification': 1 argument required, but only 0 present.\",\n      );\n    }\n    const t = String(title);\n    const opts = options ?? {};\n    const iconBytes = decodeDataUrlSync(opts.icon);\n    const instance = new NotificationNative(t, opts, iconBytes ?? undefined);\n    if (instance.notificationId !== 0) {\n      notifications.set(instance.notificationId, instance);\n    } else {\n      // Backend didn't show it (no support / failure). The native side\n      // already emitted a NotificationError event; nothing to track here.\n    }\n    return instance;\n  };\n  Object.setPrototypeOf(Notification, NotificationNative);\n  Object.setPrototypeOf(Notification.prototype, NotificationPrototype);\n  Notification.prototype.constructor = Notification;","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/rt/desktop.rs#L480-L516","documentation":"The Web Notifications API constructor is `new Notification(title, options?)` and shows the notification immediately; the title is mandatory. The desktop runtime's JS wrapper (embedded in cli/rt/desktop.rs) checks `arguments.length < 1` and throws this TypeError when the constructor is called with zero arguments.","triggerScenarios":"Calling `new Notification()` with no arguments in the Deno desktop runtime. Note: `new Notification(undefined)` does NOT trigger it, because undefined is coerced to the title string 'undefined'.","commonSituations":"Notification titles sourced from config or state that was never populated; ported code that assumed a default title; refactors that dropped the first argument.","solutions":["Pass a title string as the first argument: new Notification('Backup complete').","Default the title before constructing: new Notification(title ?? 'Alert').","Skip showing the notification when no title exists instead of constructing with none."],"exampleFix":"// before\nnew Notification();\n// after\nnew Notification(title ?? 'Update available');","handlingStrategy":"validation","validationCode":"if (typeof title !== 'string' || title.length === 0) {\n  console.warn('Notification skipped: no title');\n} else {\n  new Notification(title, options);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the title as required input: validate it where notifications are queued, not at display time.","Route all notification construction through one helper so the argument check lives in a single place."],"tags":["notification","desktop","constructor","web-api"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}