Repository navigation
fix(bun): use native bun:sqlite during startup to avoid N-API crash - #11468
Merged
diegosouzapw merged 2 commits intoAug 25, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
5 tasks done
diegosouzapw
merged commit Aug 25, 2026
9ad90fe
into
cheaper-inference:release/v3.8.51
7 of 16 checks passed
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 25, 2026
…11470) Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (Bun-native SQLite infrastructure cluster; complements #11468 already merged). - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK (Docker build itself not executed in this environment; reviewed the Dockerfile.bun diff for correctness) - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for the two concrete failure modes fixed (missing postinstall.mjs during layer-cached bun install, ARM64 NAPI crash avoided by using the native bun:sqlite smoke check instead of rebuilding better-sqlite3) plus the non-root USER bun hardening.
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 25, 2026
Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (complements #11468 and #11470, both merged first). Conflicted against #11470's Dockerfile.bun hunk in the shared worktree — resolved additively (both the ownership hardening and the addon-stripping RUN block coexist, ordered so the strip runs as root before USER bun) and pushed the same resolution to this branch. - Focused test: bun-runtime-native-addon.test.mjs — 1/1 pass, part of batch's 5/5 node:test run - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for the isolated-probe root-causing (better-sqlite3 specifically, ruling out keytar/onnxruntime-node/sqlite-vec/tls-client-node/wreq-js/sharp) plus the production ARM64 evidence.
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 26, 2026
…11428) Validated in a combined dependabot worktree off release/v3.8.51 tip alongside #11426 and #11440 — a fresh npm install of all three combined (2437 packages, 0 vulnerabilities) plus full-suite validation: - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity, check:cycles — all OK, including through the @types/node 22→26 major jump - npm run lint — 0 errors (after also draining an unrelated stale-suppressions cascade, see #11596) - npm run test:vitest — 451/452 pass; the 1 failure (auto/glm materialization) is a pre-existing timing-flaky test, reproduced 11/11 pass ×3 in isolation, unrelated to this bump - Node runtime unaffected — v24.16.0 unchanged, only the type definitions moved 8 development-group updates. The bun 1.3.14→1.4.0 + @types/bun bump aligns with the Bun-native infrastructure work merged earlier today (#11468/#11470/#11471/#11482), which was built against Bun 1.4+ assumptions.
5 tasks done
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#11468) Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (Bun-native SQLite infrastructure cluster from the same contributor). - Focused test: bunSqliteAdapter.test.ts — part of batch's 5/5 node:test run - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for tracing this to the pre-boot better-sqlite3 require — a native NAPI abort that JS try/catch cannot recover from is exactly the kind of failure mode that needs the guard moved earlier, and aligning bootstrap/sync-env with the already-preferred bun:sqlite driver is the right fix.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#11470) Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (Bun-native SQLite infrastructure cluster; complements cheaper-inference#11468 already merged). - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK (Docker build itself not executed in this environment; reviewed the Dockerfile.bun diff for correctness) - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for the two concrete failure modes fixed (missing postinstall.mjs during layer-cached bun install, ARM64 NAPI crash avoided by using the native bun:sqlite smoke check instead of rebuilding better-sqlite3) plus the non-root USER bun hardening.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…nce#11482) Validated in a combined 4-PR batch worktree off release/v3.8.51 tip (complements cheaper-inference#11468 and cheaper-inference#11470, both merged first). Conflicted against cheaper-inference#11470's Dockerfile.bun hunk in the shared worktree — resolved additively (both the ownership hardening and the addon-stripping RUN block coexist, ordered so the strip runs as root before USER bun) and pushed the same resolution to this branch. - Focused test: bun-runtime-native-addon.test.mjs — 1/1 pass, part of batch's 5/5 node:test run - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK - Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff Thanks for the isolated-probe root-causing (better-sqlite3 specifically, ruling out keytar/onnxruntime-node/sqlite-vec/tls-client-node/wreq-js/sharp) plus the production ARM64 evidence.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#11428) Validated in a combined dependabot worktree off release/v3.8.51 tip alongside cheaper-inference#11426 and cheaper-inference#11440 — a fresh npm install of all three combined (2437 packages, 0 vulnerabilities) plus full-suite validation: - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity, check:cycles — all OK, including through the @types/node 22→26 major jump - npm run lint — 0 errors (after also draining an unrelated stale-suppressions cascade, see cheaper-inference#11596) - npm run test:vitest — 451/452 pass; the 1 failure (auto/glm materialization) is a pre-existing timing-flaky test, reproduced 11/11 pass ×3 in isolation, unrelated to this bump - Node runtime unaffected — v24.16.0 unchanged, only the type definitions moved 8 development-group updates. The bun 1.3.14→1.4.0 + @types/bun bump aligns with the Bun-native infrastructure work merged earlier today (cheaper-inference#11468/cheaper-inference#11470/cheaper-inference#11471/cheaper-inference#11482), which was built against Bun 1.4+ assumptions.
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.
Summary
Avoids loading the
better-sqlite3native Node-API.nodebinary during Bun startup inbootstrap-env.mjs,sync-env.mjs, andsqliteRuntime.mjs. When running under Bun (process.versions.bun), these pre-server bootstrap paths now use the nativebun:sqlitebuilt-in driver directly.Root Cause & Motivation
When running under Bun on Linux ARM64 (e.g.
bun dev/run-standalone.mjs),hasEncryptedCredentialsinbootstrap-env.mjsran before OmniRoute's main database driver initialized. Callingrequire("better-sqlite3")triggered a native Node-API crash:Because native aborts cannot be trapped by JavaScript
try/catch, this crashed the process before server boot.OmniRoute already supports and prefers
bun:sqlitewhen running under Bun (driverFactory.ts). This fix aligns the bootstrap and environment utilities with that existing design.Key Changes
scripts/build/bootstrap-env.mjs: Whenprocess.versions.bunis detected, userequire("bun:sqlite").Databasewith synchronous.query(...).get()instead of requiringbetter-sqlite3.scripts/dev/sync-env.mjs: Same guard added tohasEncryptedCredentials.bin/cli/runtime/sqliteRuntime.mjs: Prioritizesbun-sqlitewhenprocess.versions.bunis true.tests/unit/db-adapters/bunSqliteAdapter.test.ts: Added regression test verifyingloadSqliteRuntimeprioritizesbun:sqliteunder Bun without loadingbetter-sqlite3.better-sqlite3is still used under Node.js).Validation
bun test tests/unit/db-adapters/bunSqliteAdapter.test.ts: 3 pass, 0 fail.