Repository navigation
Conversation
Bun 1.4.4 calls sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0) once before the first open, for its bundled SQLite and a setCustomSQLite library alike. Without memory statistics PRAGMA hard_heap_limit never fails an allocation, and Bun's own suite now asserts that. CI installs bun-version: latest, so the Bun (ubuntu-latest) job started failing the two heap-budget tests whose limitBinds check expected true. Export bunSqliteTracksMemory (Bun below 1.4.4, prereleases of 1.4.4 counted as 1.4.4) and have both checks expect limitBinds to equal it. The comparison is exact both ways, so a later Bun that turns the statistics back on fails the check again. Correct the comments that said the limit binds under Bun.
rymalia
marked this pull request as ready for review
October 26, 2026 16:27
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.
Bun (ubuntu-latest) now fails in the same two tests on unrelated PRs, #1085, #1090 and #1091, all of which ran on Bun 1.4.4 because the workflow installs
bun-version: latest.mainlast passed this job on Bun 1.4.3.doctor vector sampling > the doctor check verifies large documents with duplicate paths within a 32 MiB SQLite budgetEmbedding batching > legacy fingerprint adoption reads one copy of a body shared by 200 active paths within a 16 MiB SQLite budgetBoth assert
limitBinds === true, meaning SQLite'shard_heap_limitis enforced, under Bun on Linux. That guard was added in #1020 so these tests would "fail under Bun if the limit ever stops applying rather than passing without it". The limit has now stopped applying, so the guard did its job.Cause
Bun 1.4.4 (
oven-sh/bun#45304, which consolidates the SQL drivers) turns SQLite's memory statistics off once, before the first open:Without memory statistics,
PRAGMA hard_heap_limitnever fails an allocation. Bun's own suite now asserts that (test/js/bun/sqlite/sqlite.test.js: "PRAGMA hard_heap_limit does not fail allocations"). The call also runs fromDatabase.setCustomSQLite(), so loading a different SQLite library doesn't bring the limit back. The build defines inscripts/build/deps/sqlite.tsare the same in 1.4.3 and 1.4.4, so this is a runtime change, not a build flag.I checked it on macOS with the Homebrew SQLite that
src/db.tsloads throughsetCustomSQLite, usingheapLimitBinds' own probe:limitBindsChange (tests only)
test/_helpers/heap-limit.ts: exportsbunSqliteTracksMemory, which isisBun && !Bun.semver.satisfies(Bun.version, ">=1.4.4"), with a comment pointing at the Bun change.limitBindsto equalbunSqliteTracksMemory, where they used to expecttrue. The comparison is exact in both directions: if a later Bun turns the statistics back on, the check fails again, which is the cue to bound the version range.The workflow stays on
bun-version: latest. Pinning 1.4.3 would make the job green, but 1.4.3 predates the Brotli decoder fix that shipped in 1.4.4: the patchedFORMAT_BLOCK_SWITCHhandling appears 0 times in the 1.4.3 binary and 3 times in 1.4.4. It would also only postpone the failure, since the change in Bun is deliberate.What this leaves open
None of qmd's runtimes now enforces these SQLite budgets: better-sqlite3 is built with
SQLITE_DEFAULT_MEMSTATUS=0, and Bun ≥1.4.4 turns statistics off. The four heap-budget tests from #978, #995 and #1020 still check their results, but they no longer prove the memory bound. If that bound matters, the tests could measure it independently of SQLite, for example by having the worker report its peak RSS (VmHWMin/proc/self/statuson Linux) and checking it against the budget. That would hold on both Node and Bun. I left that out to keep this PR to the CI fix, but I'm happy to follow up if you'd like it.Verification
npx tsc --noEmit -p tsconfig.jsonandnpx oxlint: cleanbunSqliteTracksMemorymatches thelimitBindseach worker actually reports on macOS with Homebrew SQLite: true under Bun 1.4.3, false under Bun 1.4.4. Under Node it is false, becauseisBunshort-circuits it.