{"record":{"id":"6dd5c62445479841","repo":"denoland/deno","slug":"failed-to-execute-observe-on-performanceobserve-6dd5c6","errorCode":null,"errorMessage":"Failed to execute 'observe' on 'PerformanceObserver': Cannot specify both 'entryTypes' and 'type'.","messagePattern":"Failed to execute 'observe' on 'PerformanceObserver': Cannot specify both 'entryTypes' and 'type'\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":512,"sourceCode":"    }\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\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) =>","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L494-L530","documentation":"PerformanceObserver.observe() accepts exactly one way to select entries: the legacy `entryTypes` array or the newer `type` string (added for buffered entry observation). The Web Performance API forbids passing both in the same options object, and Deno enforces this in ext/web/15_performance.js before any other validation. Deno's supported entry types are only \"mark\" and \"measure\". The error is a TypeError thrown synchronously from observe().","triggerScenarios":"Calling `new PerformanceObserver(cb).observe({ entryTypes: [\"mark\"], type: \"measure\" })`; copying code that merged an entryTypes-based snippet with a type-based snippet; spreading a defaults object that already contains entryTypes and then adding type.","commonSituations":"Migrating from the deprecated entryTypes API to the type API and leaving the old key behind; combining options objects via object spread where one contributor supplies entryTypes and another supplies type; adapting browser examples (resource, navigation, longtask types) that were partly rewritten for Deno.","solutions":["Delete one of the two keys so the options object has either entryTypes or type, never both.","For observing a single kind of entry, keep `type` and drop entryTypes, e.g. observe({ type: \"mark\", buffered: true }).","For observing several kinds, keep the array form: observe({ entryTypes: [\"mark\", \"measure\"] }).","If you build options dynamically, filter keys before passing: only allow one of entryTypes/type through."],"exampleFix":"// before\nobserver.observe({ entryTypes: [\"mark\", \"measure\"], type: \"mark\" });\n\n// after\nobserver.observe({ entryTypes: [\"mark\", \"measure\"] });\n// or, single-type form:\nobserver.observe({ type: \"mark\", buffered: true });","handlingStrategy":"validation","validationCode":"function safeObserve(observer, options) {\n  const hasEntry = \"entryTypes\" in options;\n  const hasType = \"type\" in options;\n  if (hasEntry && hasType) {\n    throw new Error(\"Pass either entryTypes or type, not both\");\n  }\n  if (!hasEntry && !hasType) {\n    throw new Error(\"Pass one of entryTypes or type\");\n  }\n  observer.observe(options);\n}","typeGuard":"function isObserveOptions(o) {\n  const hasEntry = o != null && \"entryTypes\" in o;\n  const hasType = o != null && \"type\" in o;\n  return hasEntry !== hasType; // exactly one\n}","tryCatchPattern":"try { observer.observe(opts); } catch (e) { if (e instanceof TypeError && e.message.includes(\"entryTypes\")) fixOptions(); else throw e; }","preventionTips":["Build observe options in one place with a discriminated type: { entryTypes: string[] } | { type: string }.","Never spread two options objects together when both may carry selection keys.","Cover observer setup with a unit test asserting both invalid combinations throw."],"tags":["performance","performanceobserver","web-api","typeerror"],"backgroundTag":"conflicting-options-parameters","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}