DIYgod/RSSHub · error

execFileSync is not supported in Cloudflare Workers

Error message

execFileSync is not supported in Cloudflare Workers

What it means

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.

Source

Thrown at lib/shims/node-module.ts:96

};

// 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,

    util,
    stream,

View on GitHub (pinned to bed535e087)

Solutions

  1. Replace execFileSync with execSync (which is stubbed) if a generic shell command fits, or remove the probe.
  2. Make the probe lazy/guarded so it never runs under Workers.
  3. Deploy the route on Node.

Example fix

// before
const v = require('child_process').execFileSync('node', ['-v']).toString();
// after
const v = require('child_process').execSync('node -v').toString() || 'unknown';
Defensive patterns

Strategy: validation

Validate before calling

const isNode = typeof process !== 'undefined' && !!process.versions?.node;
if (!isNode) {
  // Workers: execFileSync throws — use execSync (stubbed to '') or skip 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').execFileSync(bin, args);
  return Buffer.from('');
} catch (e) {
  if (isWorkersShimError(e)) return Buffer.from('');
  throw e;
}

Prevention

When it happens

Trigger: A CJS dependency (via createRequire) calling child_process.execFileSync(bin, args) synchronously under Workers.

Common situations: Libraries that probe the system synchronously (e.g. detect a binary's version); tooling reused outside its intended runtime.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/a19b9a6ea52ca8b8. Report an issue: GitHub.