{"record":{"id":"96e9563d917206ed","repo":"denoland/deno","slug":"err-invalid-arg-type-96e956","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"signal\" argument must be an instance of AbortSignal. Received undefined","messagePattern":"The \"signal\" argument must be an instance of AbortSignal\\. Received undefined","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/util.ts","lineNumber":280,"sourceCode":"      deprecated.prototype = fn.prototype;\n    }\n\n    ObjectDefineProperty(deprecated, \"length\", {\n      __proto__: null,\n      ...ObjectGetOwnPropertyDescriptor(fn, \"length\"),\n    });\n  }\n\n  return deprecated;\n}\n\n// deno-lint-ignore require-await\nasync function aborted(\n  signal,\n  resource,\n) {\n  if (signal === undefined) {\n    throw new ERR_INVALID_ARG_TYPE(\"signal\", \"AbortSignal\", signal);\n  }\n  validateAbortSignal(signal, \"signal\");\n  validateObject(resource, \"resource\", {\n    allowArray: true,\n    allowFunction: true,\n  });\n  if (signal.aborted) {\n    return PromiseResolve();\n  }\n  const abortPromise = PromiseWithResolvers();\n  const resourceRef = new SafeWeakRef(resource);\n  const algorithm = () => {\n    abortedRegistry.unregister(algorithm);\n    if (WeakRefPrototypeDeref(resourceRef) !== undefined) {\n      abortPromise.resolve();\n    }\n  };\n  signal[abortSignal.add](algorithm);","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/util.ts#L262-L298","documentation":"util.aborted(signal, resource) resolves when an AbortSignal fires, and requires signal to be defined. Deno's polyfill checks signal === undefined first and throws ERR_INVALID_ARG_TYPE, matching Node: an omitted signal would create a listener that never fires and silently leak the resource reference.","triggerScenarios":"Calling util.aborted() with no arguments or with undefined as the signal — commonly aborted(options?.signal, resource) where the options field was never set.","commonSituations":"Optional signals destructured from config objects that were never populated; porting code where the AbortController lived elsewhere and the wiring was lost; calling aborted() before the controller exists.","solutions":["Create an AbortController and pass its signal: util.aborted(controller.signal, resource).","Default the parameter at the call site: util.aborted(signal ?? new AbortController().signal, resource).","If that code path is not abortable, skip the util.aborted() call instead of passing undefined."],"exampleFix":"// before\nconst ctrl = mayAbort ? new AbortController() : null;\nawait util.aborted(ctrl?.signal, resource); // ctrl null -> signal undefined -> throws\n\n// after\nconst ctrl = new AbortController();\nawait util.aborted(ctrl.signal, resource);","handlingStrategy":"validation","validationCode":"import { types } from \"node:util\";\n\nfunction requireSignal(signal) {\n  if (!types.isAbortSignal(signal)) {\n    throw new TypeError(\"signal must be an AbortSignal\");\n  }\n  return signal;\n}\n// util.aborted(requireSignal(signal), resource)","typeGuard":"function isAbortSignal(v) {\n  return typeof v === \"object\" && v !== null &&\n    typeof v.aborted === \"boolean\" &&\n    typeof v.addEventListener === \"function\";\n}","tryCatchPattern":null,"preventionTips":["Type the parameter as AbortSignal (not AbortSignal | undefined) in your wrappers so the compiler flags missing values.","Use util.types.isAbortSignal() when a signal crosses an API boundary.","Create the AbortController eagerly at the top of the operation instead of conditionally."],"tags":["abortsignal","util-aborted","err-invalid-arg-type","async"],"backgroundTag":"abortsignal-validation","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}