{"record":{"id":"8727251ba2a64927","repo":"denoland/deno","slug":"failed-to-execute-observe-on-performanceobserve-872725","errorCode":null,"errorMessage":"Failed to execute 'observe' on 'PerformanceObserver': 'entryTypes' must be an array.","messagePattern":"Failed to execute 'observe' on 'PerformanceObserver': 'entryTypes' must be an array\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":526,"sourceCode":"\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 {\n      if (\n        !ArrayPrototypeIncludes(PerformanceObserver.supportedEntryTypes, type)\n      ) {\n        return;\n      }\n      types = [type];\n    }\n","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L508-L544","documentation":"When observe() is called with `entryTypes`, the Web Performance API requires it to be an array of strings. Deno checks Array.isArray immediately in ext/web/15_performance.js and throws a TypeError for anything else. After the check, unsupported type names are silently filtered against PerformanceObserver.supportedEntryTypes, which in Deno is [\"mark\", \"measure\"] — filtering all entries out just makes observe() a no-op (returns without observing).","triggerScenarios":"observe({ entryTypes: \"mark\" }) — a bare string instead of a one-element array; passing a Set, comma-separated list, or iterable; passing an object like { 0: \"mark\" } that is not a real Array.","commonSituations":"Single-type observation where the author forgot the brackets; receiving the list as a delimited string from config and forgetting to split it; mixing up the entryTypes form with the type form (type takes a string, entryTypes takes an array).","solutions":["Wrap the value in an array: observe({ entryTypes: [\"mark\"] }).","If the value arrives as a string list, split it first: options.entryTypes.split(\",\").map((s) => s.trim()).","Use the singular `type` option instead when observing exactly one entry type.","Stick to \"mark\" and \"measure\" — other names are silently dropped in Deno."],"exampleFix":"// before\nobserver.observe({ entryTypes: \"mark\" });\n\n// after\nobserver.observe({ entryTypes: [\"mark\"] });","handlingStrategy":"type-guard","validationCode":"if (!Array.isArray(opts.entryTypes)) {\n  opts.entryTypes = [String(opts.entryTypes)];\n}\nobserver.observe(opts);","typeGuard":"function isEntryTypesArray(v) {\n  return Array.isArray(v) && v.every((t) => typeof t === \"string\");\n}","tryCatchPattern":"try { observer.observe(opts); } catch (e) { if (e instanceof TypeError && e.message.includes(\"must be an array\")) { opts.entryTypes = [opts.entryTypes]; observer.observe(opts); } else throw e; }","preventionTips":["Prefer the singular `type` option when observing one entry type.","When accepting list-like config, normalize to an array at the boundary.","Cross-check names against PerformanceObserver.supportedEntryTypes to avoid silent no-ops."],"tags":["performance","performanceobserver","web-api","typeerror"],"backgroundTag":"wrong-argument-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}