{"record":{"id":"11f8d5f5579abf82","repo":"denoland/deno","slug":"err-invalid-arg-type-11f8d5","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"channel\" argument must be one of type string or symbol. Received ${actual}","messagePattern":"The \"channel\" argument must be one of type string or symbol\\. Received (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/diagnostics_channel.js","lineNumber":254,"sourceCode":"  get hasSubscribers() {\n    return false;\n  }\n\n  publish() {}\n\n  runStores(_data, fn, thisArg, ...args) {\n    return ReflectApply(fn, thisArg, args);\n  }\n}\n\nconst channels = new WeakRefMap();\n\nfunction channel(name) {\n  const ch = channels.get(name);\n  if (ch) return ch;\n\n  if (typeof name !== \"string\" && typeof name !== \"symbol\") {\n    throw new ERR_INVALID_ARG_TYPE(\"channel\", [\"string\", \"symbol\"], name);\n  }\n\n  return new Channel(name);\n}\n\nfunction subscribe(name, subscription) {\n  return channel(name).subscribe(subscription);\n}\n\nfunction unsubscribe(name, subscription) {\n  return channel(name).unsubscribe(subscription);\n}\n\nfunction hasSubscribers(name) {\n  const ch = channels.get(name);\n  if (!ch) return false;\n\n  return ch.hasSubscribers;","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/diagnostics_channel.js#L236-L272","documentation":"diagnostics_channel.channel(name) (and everything built on it: subscribe(), unsubscribe(), TracingChannel's string form) requires the channel identifier to be a string or a symbol. The WeakRefMap cache is consulted first, but a non-string/non-symbol name is never cached, so it always falls through to this ERR_INVALID_ARG_TYPE.","triggerScenarios":"dc.channel(42); dc.subscribe(['http'], fn); dc.unsubscribe(null, fn); new TracingChannel({ toString: () => 'x' }) paths that stringify late — anything where the name is not literally string or symbol.","commonSituations":"Names built from enums stored as numbers, values read from structured config, iterating object keys with a numeric index, or passing a channel object where the name is expected.","solutions":["Coerce to string explicitly: dc.channel(String(name))","Use Symbol.for('namespace:channel') for collision-free symbolic names","If you already hold a Channel instance, use it directly instead of calling channel() again"],"exampleFix":"// before\nconst name = 42; // from a numeric enum\nconst ch = dc.channel(name); // throws\n\n// after\nconst ch = dc.channel(String(name));","handlingStrategy":"type-guard","validationCode":"const name2 = typeof name === 'symbol' ? name : String(name);\nconst ch = dc.channel(name2);","typeGuard":"const isChannelName = (v) => typeof v === 'string' || typeof v === 'symbol';","tryCatchPattern":null,"preventionTips":["Stringify numeric enum values at the channel boundary","Create channels once in a registry module and pass Channel objects around, not names","Use Symbol.for for namespaced channels when string collisions are a risk"],"tags":["node-compat","diagnostics-channel","validation","observability"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}