{"record":{"id":"4dafe547ed2a67ea","repo":"DIYgod/RSSHub","slug":"spawnsync-is-not-supported-in-cloudflare-workers","errorCode":null,"errorMessage":"spawnSync is not supported in Cloudflare Workers","messagePattern":"spawnSync is not supported in Cloudflare Workers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/shims/node-module.ts","lineNumber":99,"sourceCode":"const child_process = {\n    execSync: (_command: string): Buffer => Buffer.from(''),\n    exec: () => {\n        throw new Error('exec is not supported in Cloudflare Workers');\n    },\n    spawn: () => {\n        throw new Error('spawn is not supported in Cloudflare Workers');\n    },\n    fork: () => {\n        throw new Error('fork is not supported in Cloudflare Workers');\n    },\n    execFile: () => {\n        throw new Error('execFile is not supported in Cloudflare Workers');\n    },\n    execFileSync: () => {\n        throw new Error('execFileSync is not supported in Cloudflare Workers');\n    },\n    spawnSync: () => {\n        throw new Error('spawnSync is not supported in Cloudflare Workers');\n    },\n};\n\n// Create a CJS-compatible events module\n// In CJS, require('events') returns EventEmitter class directly (the default export)\n// but also has named exports attached to it\nconst eventsModule = Object.assign(events, eventsNamespace);\n\n// Map of module names to their exports\nconst builtinModules: Record<string, unknown> = {\n    fs,\n    path,\n\n    util,\n    stream,\n    events: eventsModule,\n    buffer,\n    crypto,","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/shims/node-module.ts#L81-L117","documentation":"Inline child_process.spawnSync() in lib/shims/node-module.ts throws. Synchronous subprocess spawning is impossible in the Workers runtime; spawnSync joins the other hard-fail spawn-family members. Only execSync is given an empty-Buffer stub.","triggerScenarios":"A CJS dependency reached via createRequire that calls child_process.spawnSync(bin, args) under Workers.","commonSituations":"Synchronous binary probes; libraries that block on a subprocess result.","solutions":["Remove the spawnSync code path under Workers.","Use execSync's no-op stub pattern if a generic command and degraded empty result are acceptable.","Run on Node."],"exampleFix":"// before\nrequire('child_process').spawnSync('git', ['rev-parse', 'HEAD']);\n// after\nrequire('child_process').execSync('git rev-parse HEAD'); // returns '' under Workers","handlingStrategy":"validation","validationCode":"const isNode = typeof process !== 'undefined' && !!process.versions?.node;\nif (!isNode) {\n  // Workers: spawnSync throws — use execSync (stubbed) or remove the probe\n}","typeGuard":"function isWorkersShimError(e: unknown): e is Error {\n  return e instanceof Error && /not supported in Cloudflare Workers/.test(e.message);\n}","tryCatchPattern":"try {\n  if (isNode) return require('child_process').spawnSync(bin, args);\n  return { stdout: Buffer.from('') };\n} catch (e) {\n  if (isWorkersShimError(e)) return { stdout: Buffer.from('') };\n  throw e;\n}","preventionTips":["Use execSync (stubbed to empty) instead of spawnSync under Workers where possible.","Remove synchronous binary probes from Worker paths.","Run spawnSync-dependent logic on Node."],"tags":["cloudflare-workers","child-process","cjs","shim","runtime"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}