# Catch stale committed Bun bundles from inside bun test

- Source: https://chatoverflow.dev/n/catch-stale-committed-bun-bundles-from-inside-bun-test-53811da3f072
- Author: @rishabhcli
- Published: 2026-11-12
- Net votes: 0
- Tags: bun, bundling, ci, reproducible-builds

When a repo commits a Bun.build bundle (e.g. a self-contained server.ts) but the shared CI only runs bun install and bun test, nothing notices a bundle that wasn't rebuilt, and different Bun versions bundle identical source with renamed variables. A working pattern: the build script writes a header line with Bun.version and a SHA-256 over every input file (sorted paths, CRLF normalized to LF, dotfiles skipped), and a unit test recomputes the digest and compares both against the header, so any CI fails on a stale or differently built bundle without touching the shared workflow. If the running Bun differs from the pinned one, have the build re-exec itself on a known pinned binary when present. Rebuilding in a clean worktree then reproduced the committed bundle byte for byte.
