{"record":{"id":"aa53ffe0c33fe97e","repo":"denoland/deno","slug":"failed-to-construct-performanceobserver-the-cal","errorCode":null,"errorMessage":"Failed to construct 'PerformanceObserver': The callback provided as parameter 1 is not a function.","messagePattern":"Failed to construct 'PerformanceObserver': The callback provided as parameter 1 is not a function\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":491,"sourceCode":"const _entryTypes = Symbol(\"[[entryTypes]]\");\nconst _buffer = Symbol(\"[[buffer]]\");\nconst _scheduled = Symbol(\"[[scheduled]]\");\n\nclass PerformanceObserver {\n  static get supportedEntryTypes() {\n    return [\"mark\", \"measure\"];\n  }\n\n  [_callback] = null;\n  [_entryTypes] = [];\n  [_buffer] = [];\n  [_scheduled] = false;\n\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;","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L473-L509","documentation":"The PerformanceObserver constructor requires one argument that is a function (ext/web/15_performance.js:487-494). After webidl's required-arguments check passes, a callback that is not a function throws TypeError \"Failed to construct 'PerformanceObserver': The callback provided as parameter 1 is not a function.\" The callback is stored and later invoked with PerformanceObserverEntryList snapshots.","triggerScenarios":"`new PerformanceObserver(null)`; `new PerformanceObserver('onMeasure')` (string instead of function); passing a value from a broken import that evaluated to undefined.","commonSituations":"Passing an options object instead of a callback; stubbing callbacks in tests with plain objects; wrong or missing imports yielding undefined; copy-paste from addEventListener-style APIs.","solutions":["Pass a function: `new PerformanceObserver((list) => ...)`.","Check the imported symbol exists and is a function before constructing.","In tests, stub with `() => {}` rather than object literals."],"exampleFix":"// before\nnew PerformanceObserver({ onmeasure: handle });\n\n// after\nnew PerformanceObserver((list) => handle(list.getEntries()));","handlingStrategy":"type-guard","validationCode":"if (typeof callback !== \"function\") {\n  throw new TypeError(\"PerformanceObserver requires a function callback\");\n}\nconst obs = new PerformanceObserver(callback);","typeGuard":"const isObserverCallback = (v) => typeof v === \"function\";","tryCatchPattern":null,"preventionTips":["Pass a function literal or verified callback; not an options object or string.","Check imported handlers are defined before constructing observers.","In tests, stub callbacks with () => {}."],"tags":["performance","performance-observer","callback","typeerror"],"backgroundTag":"callback-not-a-function","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}