{"record":{"id":"8a55f017bdbe7f08","repo":"DIYgod/RSSHub","slug":"exec-is-not-supported-in-cloudflare-workers-8a55f0","errorCode":null,"errorMessage":"exec is not supported in Cloudflare Workers","messagePattern":"exec is not supported in Cloudflare Workers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/shims/node-module.ts","lineNumber":84,"sourceCode":"    },\n    runInNewContext: () => {\n        throw new Error('vm.runInNewContext is not supported in Workers');\n    },\n    runInThisContext: () => {\n        throw new Error('vm.runInThisContext is not supported in Workers');\n    },\n    Script: ScriptShim,\n    isContext: () => false,\n    compileFunction: () => {\n        throw new Error('vm.compileFunction is not supported in Workers');\n    },\n};\n\n// Child process shim (inline to avoid import cycle)\nconst 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","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/shims/node-module.ts#L66-L102","documentation":"Inline child_process.exec() inside lib/shims/node-module.ts throws. This mirrors lib/shims/node-child-process.ts because the createRequire builtin map must expose child_process to CJS callers — but exec itself stays unsupported under Workers. Only execSync is stubbed (returns empty Buffer).","triggerScenarios":"A CJS dependency resolved through module.createRequire(...) that calls child_process.exec() at runtime under Workers.","commonSituations":"A transitive dependency that shells out; bundler-resolved CJS lib probing for git/shell tools.","solutions":["Ensure the dependency does not reach the exec path under Workers (lazy/guarded).","Substitute execSync's no-op pattern where a degraded empty result is tolerable.","Run the consuming route on Node."],"exampleFix":"// before\nconst cp = require('child_process');\ncp.exec('git log -1', cb);\n// after\nconst cp = require('child_process');\nconst out = cp.execSync('git log -1').toString() || 'unknown'; // shim returns ''","handlingStrategy":"validation","validationCode":"const isNode = typeof process !== 'undefined' && !!process.versions?.node;\n// in CJS-consuming code:\nif (isNode) {\n  require('child_process').exec(cmd, cb);\n} else {\n  // Workers: use execSync stub or fetch\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) require('child_process').exec(cmd, cb);\n  else return '';\n} catch (e) {\n  if (isWorkersShimError(e)) return '';\n  throw e;\n}","preventionTips":["Audit CJS dependencies reached via createRequire for shell-out calls.","Prefer execSync (shimmed) over exec where a degraded result is acceptable.","Deploy shell-using routes 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"}