DIYgod/RSSHub · error
execFile is not supported in Cloudflare Workers
Error message
execFile is not supported in Cloudflare Workers
What it means
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.
Source
Thrown at lib/shims/node-module.ts:93
compileFunction: () => {
throw new Error('vm.compileFunction is not supported in Workers');
},
};
// Child process shim (inline to avoid import cycle)
const child_process = {
execSync: (_command: string): Buffer => Buffer.from(''),
exec: () => {
throw new Error('exec is not supported in Cloudflare Workers');
},
spawn: () => {
throw new Error('spawn is not supported in Cloudflare Workers');
},
fork: () => {
throw new Error('fork is not supported in Cloudflare Workers');
},
execFile: () => {
throw new Error('execFile is not supported in Cloudflare Workers');
},
execFileSync: () => {
throw new Error('execFileSync is not supported in Cloudflare Workers');
},
spawnSync: () => {
throw new Error('spawnSync is not supported in Cloudflare Workers');
},
};
// Create a CJS-compatible events module
// In CJS, require('events') returns EventEmitter class directly (the default export)
// but also has named exports attached to it
const eventsModule = Object.assign(events, eventsNamespace);
// Map of module names to their exports
const builtinModules: Record<string, unknown> = {
fs,
path,View on GitHub (pinned to bed535e087)
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.
Example fix
// before
require('child_process').execFile('convert', [src, 'out.png'], cb);
// after — use a Workers-compatible image library or fetch-based service Defensive patterns
Strategy: validation
Validate before calling
const isNode = typeof process !== 'undefined' && !!process.versions?.node;
if (!isNode) {
// Workers: replace require('child_process').execFile with a native/fetch API
} Type guard
function isWorkersShimError(e: unknown): e is Error {
return e instanceof Error && /not supported in Cloudflare Workers/.test(e.message);
} Try / catch
try {
if (isNode) require('child_process').execFile(bin, args, cb);
else return fetch(serviceUrl);
} catch (e) {
if (isWorkersShimError(e)) return fetch(serviceUrl);
throw e;
} Prevention
- Do not wrap external binaries via execFile under Workers.
- Use a Workers-compatible library or remote service instead.
- Audit CJS deps for binary invocation.
When it happens
Trigger: A CJS dependency reached via createRequire that calls child_process.execFile(bin, args, cb) under Workers.
Common situations: Wrappers around specific binaries (imagemagick, curl) loaded through CJS; build-tooling reused at runtime.
Related errors
- exec is not supported in Cloudflare Workers
- spawn is not supported in Cloudflare Workers
- fork is not supported in Cloudflare Workers
- execFileSync is not supported in Cloudflare Workers
- spawnSync is not supported in Cloudflare Workers
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/b0ba20a2366d7bb8.
Report an issue: GitHub.