Skip to content

fix(db): close failed initialization connections - #13342

Merged
diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.51from
voidstackloop:fix/db-init-handle-leak-13303
Sep 18, 2026
Merged

diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.51from
voidstackloop:fix/db-init-handle-leak-13303

Conversation

@voidstackloop

Copy link
Copy Markdown
Contributor

Summary

  • close failed read-only probes before recovery snapshots or renames the database
  • close the primary SQLite connection when initialization throws before singleton ownership
  • upgrade legacy call_logs columns before schema indexes reference them

Validation

  • tests/unit/db-core-init.test.ts: 14/14 passed on Windows
  • npm run typecheck:core
  • npm run check:cycles
  • prettier --check src/lib/db/core.ts
  • ESLint reports only the three pre-existing unused-symbol errors in core.ts

⚠️ base-red inherited: #13319

Fixes #13303

…t-handle-leak-13303-conflicts

# Conflicts:
#	src/lib/db/core.ts
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks for tracking down the Windows handle-leak in getDbInstance() — closing
the probe/primary connections on every failure path (not just the happy path) is
exactly right for #13303. Ran your changed test file at this PR's head:
tests/unit/db-core-init.test.ts — 14/14 pass. One ask before merge: could you
add a changelog.d/fixes/ fragment for #13303 (repo convention, missing from
this diff)? Everything else looks solid.

voidstackloop and others added 2 commits September 15, 2026 20:31
Resolves the conflict in src/lib/db/core.ts — the base moved the startup health-check while this branch wrapped the init in try/finally (whole-block re-indent). Took the base's file and re-applied this PR's real delta (+23/-1 ignoring whitespace): probe hoisted + closed in catch/finally, and the real connection closed when init throws before setDb. typecheck:core clean, 155 DB tests green.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @voidstackloop — merging via the release merge-train. Validated in local merge-train /tmp/mt-train3b.log on 192.168.0.113 @ train tip 408e2128791696a18966681953136fc96aeb99b0 (32 PRs boarded): static gates green; full test:unit 40694 tests, 17 failing — every one reproduces on the pure release tip (base-red sweep list), zero new reds. Merged --admin per merge-gates §4/§7.

@diegosouzapw
diegosouzapw merged commit c07cebb into cheaper-inference:release/v3.8.51 Sep 18, 2026
3 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…3342)

* fix(db): close failed initialization connections

* docs: add changelog fragment for cheaper-inference#13303 db handle-leak fix

---------

Co-authored-by: voidstackloop <voidstackloop@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(backend): openDatabase() leaks the SQLite connection when init throws (EPERM on Windows teardown)

2 participants