denoland/deno · error · TypeError
Failed to construct 'Notification': 1 argument required, but
Error message
Failed to construct 'Notification': 1 argument required, but only 0 present.
What it means
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.
Source
Thrown at cli/rt/desktop.rs:498
return out;
}
return new TextEncoder().encode(decodeURIComponent(payload));
} catch {
return null;
}
}
const NotificationPrototype = NotificationNative.prototype;
Object.setPrototypeOf(NotificationPrototype, EventTarget.prototype);
const notifications = new Map();
// The Web Notifications API constructor is `new Notification(title, options?)`
// and shows the notification immediately. The native constructor takes
// a third arg for pre-decoded icon bytes so the icon URL → bytes step
// happens on the JS side (sync data: URL decoding only).
const Notification = function Notification(title, options) {
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'Notification': 1 argument required, but only 0 present.",
);
}
const t = String(title);
const opts = options ?? {};
const iconBytes = decodeDataUrlSync(opts.icon);
const instance = new NotificationNative(t, opts, iconBytes ?? undefined);
if (instance.notificationId !== 0) {
notifications.set(instance.notificationId, instance);
} else {
// Backend didn't show it (no support / failure). The native side
// already emitted a NotificationError event; nothing to track here.
}
return instance;
};
Object.setPrototypeOf(Notification, NotificationNative);
Object.setPrototypeOf(Notification.prototype, NotificationPrototype);
Notification.prototype.constructor = Notification;View on GitHub (pinned to 89f33cbef2)
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.
Example fix
// before new Notification(); // after new Notification(title ?? 'Update available');
Defensive patterns
Strategy: validation
Validate before calling
if (typeof title !== 'string' || title.length === 0) {
console.warn('Notification skipped: no title');
} else {
new Notification(title, options);
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: Notification titles sourced from config or state that was never populated; ported code that assumed a default title; refactors that dropped the first argument.
Related errors
- Notification.requestPermission: not supported by this platfo
- Failed to execute 'query' on 'Permissions': descriptor requi
- 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/440b584d7e0adc1d.
Report an issue: GitHub.