{"record":{"id":"435bcafeda8ee4c0","repo":"denoland/deno","slug":"failed-to-execute-observe-on-performanceobserve","errorCode":null,"errorMessage":"Failed to execute 'observe' on 'PerformanceObserver': 1 argument required, but only 0 present.","messagePattern":"Failed to execute 'observe' on 'PerformanceObserver': 1 argument required, but only 0 present\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":504,"sourceCode":"\n  constructor(callback) {\n    const prefix = \"Failed to construct 'PerformanceObserver'\";\n    webidl.requiredArguments(arguments.length, 1, prefix);\n    if (typeof callback !== \"function\") {\n      throw new TypeError(\n        `${prefix}: The callback provided as parameter 1 is not a function.`,\n      );\n    }\n    this[webidl.brand] = webidl.brand;\n    this[_callback] = callback;\n  }\n\n  observe(options = { __proto__: null }) {\n    webidl.assertBranded(this, PerformanceObserverPrototype);\n    const prefix = \"Failed to execute 'observe' on 'PerformanceObserver'\";\n\n    if (options === undefined || options === null) {\n      throw new TypeError(\n        `${prefix}: 1 argument required, but only 0 present.`,\n      );\n    }\n\n    const { entryTypes, type } = options;\n\n    if (entryTypes !== undefined && type !== undefined) {\n      throw new TypeError(\n        `${prefix}: Cannot specify both 'entryTypes' and 'type'.`,\n      );\n    }\n\n    if (entryTypes === undefined && type === undefined) {\n      throw new TypeError(\n        `${prefix}: Either 'entryTypes' or 'type' must be specified.`,\n      );\n    }\n","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L486-L522","documentation":"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).","triggerScenarios":"`observer.observe(null)`; `observer.observe(getOptions())` where the lookup returned null; spreading config that is typed as possibly null.","commonSituations":"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.","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."],"exampleFix":"// before\nobserver.observe(config.measureOptions ?? null);\n\n// after\nobserver.observe(config.measureOptions ?? { entryTypes: [\"measure\"] });","handlingStrategy":"validation","validationCode":"const isObserveOptions = (v) => v != null && typeof v === \"object\";\nobserver.observe(isObserveOptions(options) ? options : { entryTypes: [\"measure\"] });","typeGuard":"const isObserveOptions = (v) => v != null && typeof v === \"object\";","tryCatchPattern":null,"preventionTips":["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."],"tags":["performance","performance-observer","arguments","typeerror"],"backgroundTag":"missing-required-argument","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}