chore(bun): bump to 1.4.1 to fix the bun:sql jsonb memory leak - #212
Merged
Merged
Conversation
Bun 1.4.1 ships the fix for the bun:sql jsonb native memory leak that forced the revert to 1.3.14 in v3.3.6 (oven-sh/bun#40102, fixed by oven-sh/bun#40238). Verified against a real Postgres with 300 jsonb-bound queries of ~780 KB: 1.4.0 grows 33 -> 128 MB and keeps climbing, 1.4.1 stays flat. DO NOT MERGE yet: 1.4.1 has a bundler regression that makes the compiled server fail to boot with SyntaxError: Cannot declare a var variable that shadows a let/const/class variable: 'Check2'. The bundler emits `var Check2 = Check2` beside a `let Check2` in the same scope. Waiting for 1.4.2.
Minifying identifiers shrinks the compiled server and sidesteps a Bun 1.4.1 renamer bug that emits invalid JS for Elysia, so the binary failed to start with SyntaxError: Cannot declare a var variable that shadows a let/const/class variable: 'Check2'. Upstream confirmed this approach in oven-sh/bun#41351. Minified names alone would leave stack traces hard to read, so add an inline sourcemap. Traces keep the real source file and line, which is more useful than the bundled offsets they carried before. The sourcemap costs what the minification saves, so the binary stays at 63.5 MB. Verified with 16 integration and 14 auth integration tests on Bun 1.4.1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kernoeb
force-pushed
the
chore/bun-1.4.1
branch
from
September 4, 2026 10:03
0d1f83f to
5fcb05f
Compare
kernoeb
marked this pull request as ready for review
September 4, 2026 10:04
kernoeb
enabled auto-merge (squash)
September 4, 2026 10:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumps Bun to 1.4.1, which fixes the
bun:sqljsonb memory leak that forced the revert to 1.3.14 in v3.3.6.The leak is fixed
Verified against a real Postgres with 300 jsonb-bound queries of ~780 KB each:
The fix is oven-sh/bun#40238 (
bc713f9543), confirmed an ancestor ofbun-v1.4.1. Note that #32293 (118673413c), the first PR linked on #40102, was closed unmerged and is not the fix.Why the build config changed
Bun 1.4.1 ships a bundler regression. It mis-renames identifiers when bundling Elysia and emits invalid JS, so the compiled server fails to start:
Elysia's
dist/schema.mjsholds a block-scopedlet Check2 = function…next tovar Check = Check2, and TypeBox declares a top-levelCheck. Bun renames Elysia'svar ChecktoCheck2to resolve that collision, without accounting for thelet Check2already in scope. Both packages ship valid code; the invalid line only exists once Bun combines them.Reported as oven-sh/bun#41351. Confirmed upstream, fix open at #41354.
The workaround is
minify.identifiers: true, endorsed by Jarred on that issue: the identifier minifier uses a different renamer that is not affected. Affected range is elysia >= 1.4.28, confirmed by sweeping 1.4.25 to 1.4.30.Minified names alone would make stack traces hard to read, so this also adds
sourcemap: 'inline'. Traces keep the real source file and line, which is more useful than the bundled offsets they carried before:The sourcemap costs what the minification saves, so the binary stays at 63.5 MB.
Changes
.bun-version: 1.3.14 → 1.4.1bun-typescatalog entry: 1.3.14 → 1.4.1BUN_VERSIONdefaults indocker-compose.test.ymlanddocker-compose.test-auth.ymlbun.lockregenerated with the pinned Bunapps/api/scripts/build.ts: minify identifiers, add an inline sourcemapTests
Lint, typecheck, 148 unit tests,
docker:build, 16 integration tests and 14 auth integration tests all pass on 1.4.1. The integration tests are the ones that matter here, because only they boot the compiled binary.Follow-up
None needed for the build config. Bun 1.4.2 will fix the renamer bug, but minifying identifiers stays on: it shrinks the binary, and with the inline sourcemap the stack traces are better than they were before.
🤖 Generated with Claude Code