denoland/deno · error · TypeError
Failed to execute 'observe' on 'PerformanceObserver': 1 argu
Error message
Failed to execute 'observe' on 'PerformanceObserver': 1 argument required, but only 0 present.
What it means
PerformanceObserver.observe declares a default parameter (`options = { __proto__: null }`), so a missing argument or explicit undefined becomes an empty dictionary and instead trips the later "Either 'entryTypes' or 'type' must be specified" check (ext/web/15_performance.js:517-521). This specific TypeError — "1 argument required, but only 0 present" — only fires when null is passed explicitly, because null does not trigger the default parameter (ext/web/15_performance.js:499-507).
Source
Thrown at ext/web/15_performance.js:504
constructor(callback) {
const prefix = "Failed to construct 'PerformanceObserver'";
webidl.requiredArguments(arguments.length, 1, prefix);
if (typeof callback !== "function") {
throw new TypeError(
`${prefix}: The callback provided as parameter 1 is not a function.`,
);
}
this[webidl.brand] = webidl.brand;
this[_callback] = callback;
}
observe(options = { __proto__: null }) {
webidl.assertBranded(this, PerformanceObserverPrototype);
const prefix = "Failed to execute 'observe' on 'PerformanceObserver'";
if (options === undefined || options === null) {
throw new TypeError(
`${prefix}: 1 argument required, but only 0 present.`,
);
}
const { entryTypes, type } = options;
if (entryTypes !== undefined && type !== undefined) {
throw new TypeError(
`${prefix}: Cannot specify both 'entryTypes' and 'type'.`,
);
}
if (entryTypes === undefined && type === undefined) {
throw new TypeError(
`${prefix}: Either 'entryTypes' or 'type' must be specified.`,
);
}
View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Always pass an options object: `observe({ type: 'measure', buffered: true })` or `observe({ entryTypes: ['mark', 'measure'] })`.
- Default nullish configs with `?? {}` or a meaningful fallback: `observe(options ?? { entryTypes: ['measure'] })`.
- Type the variable as an object, not `T | null`, before calling observe.
Example fix
// before
observer.observe(config.measureOptions ?? null);
// after
observer.observe(config.measureOptions ?? { entryTypes: ["measure"] }); Defensive patterns
Strategy: validation
Validate before calling
const isObserveOptions = (v) => v != null && typeof v === "object";
observer.observe(isObserveOptions(options) ? options : { entryTypes: ["measure"] }); Type guard
const isObserveOptions = (v) => v != null && typeof v === "object";
Prevention
- Always pass an options object: { entryTypes: [...] } or { type, buffered }.
- Default possibly-null configs with `?? { entryTypes: [...] }`, never leave null.
- Remember observe() with no args throws a different error ('Either entryTypes or type'); explicit null throws this one.
When it happens
Trigger: `observer.observe(null)`; `observer.observe(getOptions())` where the lookup returned null; spreading config that is typed as possibly null.
Common situations: Optional-config patterns defaulting to null; config loaders returning null for missing sections; code ported from browsers, where observe() with no args throws the same message and the mapping is surprising.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Failed to construct 'PerformanceObserver': The callback prov
- The property 'options.eval' must be false when 'filename' is
- Failed to execute 'observe' on 'PerformanceObserver': Cannot
- Failed to execute 'observe' on 'PerformanceObserver': Either
- Failed to execute 'observe' on 'PerformanceObserver': 'entry
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/435bcafeda8ee4c0.
Report an issue: GitHub.