{"record":{"id":"7ea02ab406c12256","repo":"denoland/deno","slug":"name-is-not-a-function","errorCode":null,"errorMessage":"${name} is not a function","messagePattern":"(.+?) is not a function","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/webidl/00_webidl.js","lineNumber":1010,"sourceCode":"        `${context}, index ${array.length}`,\n        opts,\n      );\n      ArrayPrototypePush(array, val);\n    }\n    return array;\n  };\n}\n\n// https://tc39.es/ecma262/#sec-getmethod\nfunction getMethod(V, P) {\n  const func = V[P];\n  if (func === undefined || func === null) {\n    return undefined;\n  }\n  if (typeof func !== \"function\") {\n    // Match engine-style key formatting: Symbol(aaa), not the bare description.\n    const name = typeof P === \"symbol\" ? SymbolPrototypeToString(P) : P;\n    throw new TypeError(`${name} is not a function`);\n  }\n  return func;\n}\n\n// Whether V is convertible to an IDL async_sequence (has a usable\n// @@asyncIterator or @@iterator method). Uses GetMethod, so non-callable\n// methods throw TypeError (same as conversion / union matching).\nfunction isAsyncSequence(obj) {\n  if (type(obj) !== \"Object\") {\n    return false;\n  }\n  if (getMethod(obj, SymbolAsyncIterator) !== undefined) {\n    return true;\n  }\n  return getMethod(obj, SymbolIterator) !== undefined;\n}\n\n// https://tc39.es/ecma262/#sec-createasyncfromsynciterator","sourceCodeStart":992,"sourceCodeEnd":1028,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/ext/webidl/00_webidl.js#L992-L1028","documentation":"Implements ECMA-262 GetMethod for WebIDL: reads property P on V; null/undefined means 'absent', but any other non-callable value throws TypeError. Symbol keys are formatted with Symbol.prototype.toString so the message reads engine-style, e.g. 'Symbol(aaa) is not a function'. Used by iterator/async-iterator protocol lookups (isAsyncSequence) and converters.","triggerScenarios":"Passing an object used as an iterable/async-iterable (e.g. a fetch body) where @@asyncIterator or @@iterator exists but is not callable, e.g. { [Symbol.asyncIterator]: 42 } or { [Symbol.iterator]: someArray }.","commonSituations":"Storing an already-called iterator under the symbol key instead of a method ({ [Symbol.asyncIterator]: stream[Symbol.asyncIterator]() }), spreading config objects that overwrite protocol methods with data values, polyfills assigning non-callable symbol properties.","solutions":["Make the property a real method: [Symbol.asyncIterator]() { return this; }","Or set the property to null/undefined (or delete it) so it counts as absent instead of invalid","Never store iterator objects under @@iterator/@@asyncIterator keys - store the iterable and let the method be invoked"],"exampleFix":"// before\nconst body = { [Symbol.asyncIterator]: source[Symbol.asyncIterator]() }; // object, not a function\n\n// after\nconst body = { [Symbol.asyncIterator]() { return source[Symbol.asyncIterator](); } };","handlingStrategy":"type-guard","validationCode":"function checkProtocolMethods(v: object, key: symbol | string) {\n  const m = (v as any)[key];\n  if (m != null && typeof m !== 'function') {\n    throw new TypeError(`${String(key)} must be a function or null`);\n  }\n}\ncheckProtocolMethods(body, Symbol.asyncIterator);","typeGuard":"const isAsyncIterable = (v: unknown): v is AsyncIterable<unknown> =>\n  v != null && typeof (v as Record<PropertyKey, unknown>)[Symbol.asyncIterator] === 'function';","tryCatchPattern":null,"preventionTips":["Use method shorthand for symbol keys: [Symbol.asyncIterator]() { ... }","Type values as AsyncIterable<T> so TypeScript flags non-callable assignments","Never store an already-called iterator under a protocol key - store the iterable"],"tags":["webidl","async-iterator","symbol","protocol","typeerror"],"backgroundTag":"asynciterator-is-not-a-function","analyzedSha":"f7822238cab635a3a19f99f493f675fa81a7f9d8","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}