{"record":{"id":"5bc13c36208d3efe","repo":"denoland/deno","slug":"err-invalid-arg-type-5bc13c","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"callback\" argument must be an instance of Function. Received ${received}","messagePattern":"The \"callback\" argument must be an instance of Function\\. Received (.+?)","errorType":"exception","errorClass":"ERR_INVALID_ARG_TYPE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/perf_hooks.js","lineNumber":102,"sourceCode":"    getEntriesByName(name, type) {\n      return ArrayPrototypeFilter(\n        entries,\n        (e) => e.name === name && (type === undefined || e.entryType === type),\n      );\n    },\n  };\n}\n\n// Node-compatible PerformanceObserver that throws proper Node.js errors\nclass PerformanceObserver extends WebPerformanceObserver {\n  [_nodeTypes] = [];\n  [_nodeBuffer] = [];\n  [_nodeScheduled] = false;\n  [_nodeCallback] = null;\n\n  constructor(callback) {\n    if (typeof callback !== \"function\") {\n      throw new ERR_INVALID_ARG_TYPE(\"callback\", \"Function\", callback);\n    }\n    super(callback);\n    this[_nodeCallback] = callback;\n  }\n\n  static get supportedEntryTypes() {\n    return [\n      ...new SafeArrayIterator(WebPerformanceObserver.supportedEntryTypes),\n      ...new SafeArrayIterator(NODE_ENTRY_TYPES),\n    ];\n  }\n\n  observe(options) {\n    if (typeof options !== \"object\" || options === null) {\n      throw new ERR_INVALID_ARG_TYPE(\"options\", \"Object\", options);\n    }\n    if (\n      options.entryTypes !== undefined && !ArrayIsArray(options.entryTypes)","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/perf_hooks.js#L84-L120","documentation":"`new PerformanceObserver(callback)` requires a function as its only argument. The perf_hooks polyfill throws ERR_INVALID_ARG_TYPE for anything else, including a missing argument. The web PerformanceObserver it extends has the same requirement.","triggerScenarios":"`new PerformanceObserver()` with no argument; passing an options object like `{ onEntry: fn }`; a callback variable that is undefined because the import binding did not exist; passing a string name of a function.","commonSituations":"Named vs default export mixups that leave an imported symbol undefined. Wrapper APIs that accept a config object where Node expects a bare function. Copy-paste from observer examples in other languages.","solutions":["Pass a function: `new PerformanceObserver((list) => { ... })`.","For class methods, pass an arrow that binds this: `(list) => this.onEntries(list)`.","Check the import when the value is undefined — verify named vs default export."],"exampleFix":"// before\nnew PerformanceObserver();\n\n// after\nnew PerformanceObserver((list) => {\n  for (const entry of list.getEntries()) console.log(entry.name);\n});","handlingStrategy":"type-guard","validationCode":"if (typeof callback !== 'function') {\n  throw new Error('PerformanceObserver needs a callback function');\n}\nconst obs = new PerformanceObserver(callback);","typeGuard":"function isObserverCallback(v: unknown): v is (list: unknown) => void {\n  return typeof v === 'function';\n}","tryCatchPattern":null,"preventionTips":["Verify imports when a callback arrives undefined (named vs default export).","Bind class methods through an arrow function so this stays correct and the value stays a function.","Type wrappers as (callback: (list: PerformanceObserverEntryList) => void) => ... so misuse fails early."],"tags":["perf-hooks","performanceobserver","invalid-argument","node-compat"],"backgroundTag":"invalid-argument-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}