DIYgod/RSSHub · error
spawn is not supported in Cloudflare Workers
Error message
spawn is not supported in Cloudflare Workers
What it means
Intentional guard in the Workers shim (lib/shims/node-child-process.ts). spawn() has no Workers equivalent (no subprocess capability), so it throws on call. Like exec(), it is fail-fast; only execSync() is stubbed with an empty-Buffer fallback.
Source
Thrown at lib/shims/node-child-process.ts:14
// Worker-specific shim for node:child_process
// This module is not available in Cloudflare Workers
export function execSync(_command: string): Buffer {
// Return empty buffer - git info will fall back to 'unknown'
return Buffer.from('');
}
export function exec() {
throw new Error('exec is not supported in Cloudflare Workers');
}
export function spawn() {
throw new Error('spawn is not supported in Cloudflare Workers');
}
View on GitHub (pinned to bed535e087)
Solutions
- Do not invoke spawn() in Worker-deployed routes.
- Detect the runtime and branch to a Workers-compatible alternative (e.g. fetch-based).
- Run that route on the Node target instead of Workers.
Example fix
// before
import { spawn } from 'node:child_process';
const p = spawn('ffmpeg', ['-i', url]);
// after — under Workers, fetch the media URL directly instead of spawning ffmpeg
const buf = await fetch(url).then((r) => r.arrayBuffer()); Defensive patterns
Strategy: validation
Validate before calling
function canSpawn(): boolean {
return typeof process !== 'undefined' && !!process.versions?.node;
}
if (!canSpawn()) {
// do not call spawn(); use fetch/stream APIs
} 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 (canSpawn()) spawnTool(args);
} catch (e) {
if (isWorkersShimError(e)) return fallbackStream();
throw e;
} Prevention
- Never call spawn() in routes that may run on Workers.
- Use fetch()/ReadableStream for I/O instead of subprocess streaming.
- Reserve subprocess routes for the Node deployment target.
When it happens
Trigger: Calling child_process.spawn(...) under the Workers build — typically a long-running subprocess, streaming tool, or a dependency that spawns helpers.
Common situations: Puppeteer/Playwright-style process launching; media tool wrappers (ffmpeg); a Node-only utility route deployed to Workers.
Related errors
- exec is not supported in Cloudflare Workers
- 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
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/16c4c8ba093bd2b8.
Report an issue: GitHub.