{"record":{"id":"d5891ca4265c00aa","repo":"denoland/deno","slug":"err-worker-unsupported-operation-d5891c","errorCode":"ERR_WORKER_UNSUPPORTED_OPERATION","errorMessage":"Setting trace SIGINT is not supported in workers","messagePattern":"Setting trace SIGINT is not supported in workers","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/util.ts","lineNumber":377,"sourceCode":"\n  return capturedTraces;\n}\n\nfunction parseEnv(input) {\n  validateString(input, \"content\");\n  const parsed = binding.parseEnv(input);\n  const result = ObjectCreate(null);\n  const keys = ObjectKeys(parsed);\n  for (let i = 0; i < keys.length; i++) {\n    result[keys[i]] = parsed[keys[i]];\n  }\n  return result;\n}\n\nfunction setTraceSigInt(enabled) {\n  validateBoolean(enabled, \"enabled\");\n  if (internals.__isWorkerThread) {\n    throw new ERR_WORKER_UNSUPPORTED_OPERATION(\"Setting trace SIGINT\");\n  }\n  // No-op on the main thread: Deno does not implement Node's SIGINT trace\n  // facility, but the call should succeed so user code can opt in/out.\n}\n\n// https://nodejs.org/api/util.html#utilqueryobjectsconstructor-options\n// Mirrors `v8.queryObjects` - see ext/node/polyfills/v8.ts for the limitations.\nfunction queryObjects(ctor, options) {\n  return lazyV8().queryObjects(ctor, options);\n}\n\n// Deno's AbortSignal is not yet structured-cloneable, so transfer is a no-op:\n// the returned signal/controller can still be used in-process. This mirrors\n// Node's API surface so user code calling these does not throw.\nfunction transferableAbortSignal(signal) {\n  if (\n    signal === null || typeof signal !== \"object\" ||\n    typeof signal.aborted !== \"boolean\"","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/util.ts#L359-L395","documentation":"util.setTraceSigInt(enabled) toggles Node's process-wide SIGINT tracing hook, which is main-thread-only. Deno's polyfill accepts the call on the main thread (as a documented no-op, since Deno has no SIGINT trace facility) but throws ERR_WORKER_UNSUPPORTED_OPERATION inside worker threads, mirroring Node: a worker cannot install the process signal tracer.","triggerScenarios":"Calling util.setTraceSigInt(true) from code running inside a Worker — new Worker(...), worker_threads, or pooled runtimes (Piscina, workerpool, test workers).","commonSituations":"CLI libraries that enable SIGINT tracing at import time and then get loaded inside Jest workers or task pools; module top-level side effects that never check isMainThread; code shared between a main process and its workers.","solutions":["Guard the call: only invoke setTraceSigInt when worker_threads.isMainThread is true.","Move setTraceSigInt out of module top-level into an explicit main-thread init function.","If tracing is required, restructure so that code path only runs in the main process, not in pool workers."],"exampleFix":"// before — module top level, runs in workers too\nutil.setTraceSigInt(true); // throws ERR_WORKER_UNSUPPORTED_OPERATION in a worker\n\n// after\nimport { isMainThread } from \"node:worker_threads\";\nif (isMainThread) util.setTraceSigInt(true);","handlingStrategy":"validation","validationCode":"import { isMainThread } from \"node:worker_threads\";\nimport util from \"node:util\";\n\nexport function safeSetTraceSigInt(enabled) {\n  if (!isMainThread) return; // no-op in workers instead of throwing\n  util.setTraceSigInt(enabled);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never put process-wide signal configuration at module top level; workers import the same module.","Audit process-global APIs (setTraceSigInt, exit hooks) for code shared with workers.","Remember Deno implements this as a no-op even on the main thread — do not rely on observable tracing effects."],"tags":["worker-threads","sigint","util","err-worker-unsupported-operation"],"backgroundTag":"worker-unsupported-operation","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"}