microsoft/TypeScript · error · Error

${task[0]} ${task[1].join(" ")} failed: ${result.stderr && "

Error message

${task[0]} ${task[1].join(" ")} failed: ${result.stderr && "stderr: " + result.stderr.toString()}${result.stdout && "\nstdout: " + result.stdout.toString()}

What it means

runSequence executes a list of [cmd, args] tasks via spawnSync (default 100s timeout, shell:true) and throws as soon as one exits with non-zero status, embedding that task's stderr and stdout in the error message.

Source

Thrown at scripts/run-sequence.mjs:14

import assert from "assert";
import cp from "child_process";

/**
 * @param {[string, string[]][]} tasks
 * @param {cp.SpawnSyncOptions} opts
 * @returns {string}
 */
export function runSequence(tasks, opts = { timeout: 100000, shell: true }) {
    let lastResult;
    for (const task of tasks) {
        console.log(`${task[0]} ${task[1].join(" ")}`);
        const result = cp.spawnSync(task[0], task[1], opts);
        if (result.status !== 0) throw new Error(`${task[0]} ${task[1].join(" ")} failed: ${result.stderr && "stderr: " + result.stderr.toString()}${result.stdout && "\nstdout: " + result.stdout.toString()}`);
        console.log(result.stdout && result.stdout.toString());
        lastResult = result;
    }
    const out = lastResult?.stdout?.toString();
    assert(out !== undefined);
    return out;
}

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Read the embedded stderr/stdout in the error to identify the failing command and its real cause.
  2. Reproduce by running that exact command manually in the same environment.
  3. Fix the underlying tool/config and ensure the binary is on PATH.
  4. If the 100s default timeout is too short, pass a larger `opts.timeout` from the caller.
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate each command exists before spawning.
import { whichSync } from "child_process";
for (const [cmd] of tasks) {
  if (!whichSync(cmd)) throw new Error(`Command not found on PATH: ${cmd}`);
}

Try / catch

try {
  return runSequence(tasks, opts);
} catch (e) {
  // re-throw with the failing task clearly identified; do not retry unchanged.
  throw new Error(`runSequence step failed: ${e.message}`, { cause: e });
}

Prevention

When it happens

Trigger: Any child process in the sequence exits non-zero: a real failure, a missing binary on PATH, or a timeout/signal kill (which also surfaces as non-zero status).

Common situations: An orchestrated release/build script where an inner step (test, lint, pack) fails; PATH not set up for the spawned binary.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/3a27a7c9e5df2178. Report an issue: GitHub.