oven-sh/bun · error · Error

workload "${workload.name}" exited ${r.status} ${r.stderr}

Error message

workload "${workload.name}" exited ${r.status}
${r.stderr}

What it means

One of the representative workloads (`bun -e`, hello.ts, server.js, `bun test`, `bun pm install`, …) run under the functrace preload exited non-zero; the workload name and its stderr are included. The generator treats any workload failure as fatal because a broken run yields an unrepresentative order file.

Source

Thrown at scripts/orderfile/generate.ts:307

      const out = join(scratch, `trace-${i}.bin`);
      // The tracer loads into the traced process and nowhere else. On a terminal
      // ptyrun is the parent, so it is the one that hands the preload down.
      const preloadVar = darwin ? "DYLD_INSERT_LIBRARIES" : "LD_PRELOAD";
      const preload = workload.tty ? { PTYRUN_PRELOAD: tracer } : { [preloadVar]: tracer };
      const r = runCommand(workload.tty ? [ptyrun, bunProfile, ...workload.args] : [bunProfile, ...workload.args], {
        env: {
          ...preload,
          BUN_FUNCTRACE_STARTS: startsPath,
          BUN_FUNCTRACE_OUT: out,
          BUN_DEBUG_QUIET_LOGS: "1",
          ...workload.env,
        },
        cwd: workload.cwd,
        input: workload.input,
        timeout: WORKLOAD_TIMEOUT_MS,
        label: `workload "${workload.name}"`,
      });
      if (r.status !== 0) throw new Error(`workload "${workload.name}" exited ${r.status}\n${r.stderr}`);

      const before = order.length;
      let unresolved = 0;
      for (const address of readTrace(out, workload.name)) {
        const names = symbols.get(address);
        if (!names) {
          unresolved++;
          continue;
        }
        for (const name of names) {
          if (seen.has(name)) continue;
          seen.add(name);
          order.push(name);
        }
      }
      const note = unresolved ? ` (${unresolved} unresolved)` : "";
      log(`  ${workload.name.padEnd(21)} +${order.length - before} functions${note}`);
    }

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Read the appended stderr — it is the workload's own failure output
  2. Re-run the same command without the BUN_FUNCTRACE_* preload env to see whether the failure is tracer-induced
  3. Re-run the generator: fixtures are recreated in a fresh scratch dir each time
  4. If it only reproduces under preload, file/inspect a tracer issue rather than skipping the workload
Defensive patterns

Strategy: try-catch

Validate before calling

import { spawnSync } from "node:child_process";

// Dry-run each workload without the tracer to separate real failures from tracer-induced ones.
for (const w of workloads) {
  const dry = spawnSync(bunProfile, w.args, { cwd: w.cwd, input: w.input });
  if (dry.status !== 0) throw new Error(`workload "${w.name}" fails even untraced — fix it before orderfile runs`);
}

Try / catch

try {
  await runWorkload(workload);
} catch (err) {
  if (/workload ".*" exited/.test(String(err))) {
    console.error(`Workload stderr is included above — rerun without BUN_FUNCTRACE_* to test tracer involvement`);
  }
  throw err;
}

Prevention

When it happens

Trigger: The profile binary crashing only when instrumented by the tracer; fixture bugs (missing files in scratch); workload-specific env (BUN_DEBUG_QUIET_LOGS plus workload.env) breaking execution. Note a timeout surfaces separately as an ETIMEDOUT spawn error (167), not as this status-based error.

Common situations: Tracer interfering with the runtime (interposition bugs); regressions in the traced build making a normal command fail; scratch fixture setup races.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/d788be094c4583e5. Report an issue: GitHub.