{"record":{"id":"a19b9a6ea52ca8b8","repo":"DIYgod/RSSHub","slug":"execfilesync-is-not-supported-in-cloudflare-worker","errorCode":null,"errorMessage":"execFileSync is not supported in Cloudflare Workers","messagePattern":"execFileSync is not supported in Cloudflare Workers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/shims/node-module.ts","lineNumber":96,"sourceCode":"};\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\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,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/shims/node-module.ts#L78-L114","documentation":"Inline child_process.execFileSync() in lib/shims/node-module.ts throws. Note the asymmetry: execSync is stubbed to return an empty Buffer (so git-info degrades to 'unknown'), but execFileSync is NOT — it throws. Workers have no synchronous subprocess execution at all.","triggerScenarios":"A CJS dependency (via createRequire) calling child_process.execFileSync(bin, args) synchronously under Workers.","commonSituations":"Libraries that probe the system synchronously (e.g. detect a binary's version); tooling reused outside its intended runtime.","solutions":["Replace execFileSync with execSync (which is stubbed) if a generic shell command fits, or remove the probe.","Make the probe lazy/guarded so it never runs under Workers.","Deploy the route on Node."],"exampleFix":"// before\nconst v = require('child_process').execFileSync('node', ['-v']).toString();\n// after\nconst v = require('child_process').execSync('node -v').toString() || 'unknown';","handlingStrategy":"validation","validationCode":"const isNode = typeof process !== 'undefined' && !!process.versions?.node;\nif (!isNode) {\n  // Workers: execFileSync throws — use execSync (stubbed to '') or skip 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').execFileSync(bin, args);\n  return Buffer.from('');\n} catch (e) {\n  if (isWorkersShimError(e)) return Buffer.from('');\n  throw e;\n}","preventionTips":["Prefer execSync over execFileSync — only the former is stubbed under Workers.","Make binary probes lazy so they never run under Workers.","Keep sync-subprocess code 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"}