DIYgod/RSSHub · error
spawnSync is not supported in Cloudflare Workers
Error message
spawnSync is not supported in Cloudflare Workers
What it means
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.
Source
Thrown at lib/shims/node-module.ts:99
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,
util,
stream,
events: eventsModule,
buffer,
crypto,View on GitHub (pinned to bed535e087)
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.
Example fix
// before
require('child_process').spawnSync('git', ['rev-parse', 'HEAD']);
// after
require('child_process').execSync('git rev-parse HEAD'); // returns '' under Workers Defensive patterns
Strategy: validation
Validate before calling
const isNode = typeof process !== 'undefined' && !!process.versions?.node;
if (!isNode) {
// Workers: spawnSync throws — use execSync (stubbed) or remove the probe
} 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) return require('child_process').spawnSync(bin, args);
return { stdout: Buffer.from('') };
} catch (e) {
if (isWorkersShimError(e)) return { stdout: Buffer.from('') };
throw e;
} Prevention
- 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.
When it happens
Trigger: A CJS dependency reached via createRequire that calls child_process.spawnSync(bin, args) under Workers.
Common situations: Synchronous binary probes; libraries that block on a subprocess result.
Related errors
- exec is not supported in Cloudflare Workers
- spawn is not supported in Cloudflare Workers
- fork is not supported in Cloudflare Workers
- execFile is not supported in Cloudflare Workers
- execFileSync is not supported in Cloudflare Workers
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/4dafe547ed2a67ea.
Report an issue: GitHub.