{"record":{"id":"b0ba20a2366d7bb8","repo":"DIYgod/RSSHub","slug":"execfile-is-not-supported-in-cloudflare-workers","errorCode":null,"errorMessage":"execFile is not supported in Cloudflare Workers","messagePattern":"execFile is not supported in Cloudflare Workers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/shims/node-module.ts","lineNumber":93,"sourceCode":"    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\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,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/shims/node-module.ts#L75-L111","documentation":"Inline child_process.execFile() in lib/shims/node-module.ts throws. Workers cannot execute any external file/binary, so execFile — like exec/spawn — is unsupported. execFileSync is also throwing; only execSync returns an empty Buffer.","triggerScenarios":"A CJS dependency reached via createRequire that calls child_process.execFile(bin, args, cb) under Workers.","commonSituations":"Wrappers around specific binaries (imagemagick, curl) loaded through CJS; build-tooling reused at runtime.","solutions":["Avoid the execFile path under Workers; use a native API or fetch equivalent.","Run the route on Node.","Stub the call with a safe no-op where a degraded result is acceptable."],"exampleFix":"// before\nrequire('child_process').execFile('convert', [src, 'out.png'], cb);\n// after — use a Workers-compatible image library or fetch-based service","handlingStrategy":"validation","validationCode":"const isNode = typeof process !== 'undefined' && !!process.versions?.node;\nif (!isNode) {\n  // Workers: replace require('child_process').execFile with a native/fetch API\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').execFile(bin, args, cb);\n  else return fetch(serviceUrl);\n} catch (e) {\n  if (isWorkersShimError(e)) return fetch(serviceUrl);\n  throw e;\n}","preventionTips":["Do not wrap external binaries via execFile under Workers.","Use a Workers-compatible library or remote service instead.","Audit CJS deps for binary invocation."],"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"}