{"record":{"id":"170ecd4ec29b6ac7","repo":"denoland/deno","slug":"failed-to-execute-observe-on-performanceobserve-170ecd","errorCode":null,"errorMessage":"Failed to execute 'observe' on 'PerformanceObserver': Either 'entryTypes' or 'type' must be specified.","messagePattern":"Failed to execute 'observe' on 'PerformanceObserver': Either 'entryTypes' or 'type' must be specified\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":518,"sourceCode":"    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\n    let types;\n    if (entryTypes !== undefined) {\n      if (!ArrayIsArray(entryTypes)) {\n        throw new TypeError(`${prefix}: 'entryTypes' must be an array.`);\n      }\n      types = ArrayPrototypeFilter(\n        entryTypes,\n        (t) =>\n          ArrayPrototypeIncludes(PerformanceObserver.supportedEntryTypes, t),\n      );\n      if (types.length === 0) {\n        return;\n      }\n    } else {","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L500-L536","documentation":"observe() on PerformanceObserver requires an options object that selects what to observe via `entryTypes` (array) or `type` (string). Passing an object with neither key, or omitting/emptying the selection, throws this TypeError from ext/web/15_performance.js. Note that passing no argument at all throws a different error (\"1 argument required\"), so this specific message means an options object was given but contained neither key.","triggerScenarios":"observe({}) or observe({ buffered: true }) with no type selection; observe(undefined-key objects) built from a variable that is undefined at runtime; destructuring or JSON-parsing a config that lost its entryTypes field.","commonSituations":"Loading observer config from JSON/env where the entryTypes field is missing or misspelled (entryTypes vs entrytypes); refactoring that renames the key in one place but not the other; passing an options object intended for a different observer API.","solutions":["Add one selection key: observe({ entryTypes: [\"mark\", \"measure\"] }) or observe({ type: \"mark\" }).","Check the spelling and case of the key — it is exactly `entryTypes` or `type`.","If the options come from config, validate they contain at least one of the two keys before calling observe.","Remember Deno only supports \"mark\" and \"measure\"; other type names are silently filtered out with entryTypes."],"exampleFix":"// before\nobserver.observe({ buffered: true });\n\n// after\nobserver.observe({ type: \"mark\", buffered: true });","handlingStrategy":"validation","validationCode":"if (!(\"entryTypes\" in opts || \"type\" in opts)) {\n  opts = { entryTypes: [\"mark\", \"measure\"] }; // or fail fast with your own error\n}\nobserver.observe(opts);","typeGuard":"function hasEntrySelection(o) {\n  return o != null && typeof o === \"object\" &&\n    (\"entryTypes\" in o || \"type\" in o);\n}","tryCatchPattern":"try { observer.observe(opts); } catch (e) { if (e instanceof TypeError && /entryTypes|type/.test(e.message)) applyDefaultsAndRetry(); else throw e; }","preventionTips":["Type the parameter as { entryTypes: string[] } | { type: string } so TypeScript rejects empty objects.","Validate config-derived options before passing them to observe.","Spell the key exactly 'entryTypes' (capital T) — typos silently create this error."],"tags":["performance","performanceobserver","web-api","typeerror"],"backgroundTag":"missing-required-option","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}