Skip to content
Latchkey

Bun "Segmentation fault" on the runner in CI

Bun crashed with a segfault instead of exiting cleanly. In CI this usually means the Bun binary does not match the runner CPU baseline, or a native module Bun loaded is incompatible with this Bun version.

What this error means

A Bun step aborts with "Segmentation fault (core dumped)" or "Illegal instruction", often mid-bun install or on first bun run, and reproduces only on the runner.

Terminal
bun install
Segmentation fault (core dumped)
Error: Process completed with exit code 139.

Common causes

A Bun build that needs a newer CPU baseline

The standard Bun release uses AVX2; on an older or emulated runner CPU it crashes with SIGSEGV or SIGILL.

A native addon incompatible with this Bun

A prebuilt N-API/native module built for a different ABI or Bun version can fault when Bun dlopens it.

How to fix it

Use the baseline Bun build on older CPUs

setup-bun can install the baseline variant that drops the newer CPU instruction requirement.

.github/workflows/ci.yml
- uses: oven-sh/setup-bun@v2
  with:
    bun-version: '1.1.34'
    # baseline avoids AVX2 requirement on old/emulated CPUs

Reinstall native modules against this Bun

  1. Delete node_modules and the install cache so stale native builds are dropped.
  2. Reinstall so addons are fetched or rebuilt for the runner ABI.
  3. Pin a Bun version known to work with the addon.
Terminal
rm -rf node_modules
bun install

How to prevent it

  • Pin a Bun version validated against your native dependencies.
  • Use the baseline Bun build on older or emulated runner CPUs.
  • Avoid caching node_modules across different Bun versions.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →