FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

sqlite: prevent database close during callbacks by mcollina · Pull Request #64743 · nodejs/node · GitHub

/ node Public

sqlite: prevent database close during callbacks - #64743

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:fix-sqlite-close-during-callback
Aug 4, 2026
Merged

sqlite: prevent database close during callbacks#64743
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:fix-sqlite-close-during-callback

Conversation

mcollina commented Jul 25, 2026
edited
Loading

Copy link
Copy Markdown
Member

Prevent DatabaseSync.close() from finalizing SQLite resources while a JavaScript callback is executing.

SQLite invokes user-defined functions, aggregate functions, authorizers, and changeset callbacks synchronously during database operations. Previously, calling database.close() from one of these callbacks could finalize active statements or the connection while native code was still using them.

This change tracks callback depth and rejects reentrant closes with ERR_INVALID_STATE. It also adds regression coverage for StatementSync.all(), get(), run(), and iterate().

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Jul 25, 2026

codecov Bot commented Jul 25, 2026
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.29032% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (c8e2a82) to head (a477a99).
⚠️ Report is 82 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 50.00% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #64743   +/-   ##
=======================================
  Coverage   90.16%   90.16%           
=======================================
  Files         746      746           
  Lines      242760   242784   +24     
  Branches    45765    45766    +1     
=======================================
+ Hits       218875   218902   +27     
+ Misses      15375    15367    -8     
- Partials     8510     8515    +5     
Files with missing lines Coverage Δ
src/node_sqlite.h 82.60% <100.00%> (+1.96%) ⬆️
src/node_sqlite.cc 80.43% <50.00%> (-0.25%) ⬇️

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mcollina force-pushed the fix-sqlite-close-during-callback branch 2 times, most recently from d3160fe to 822fbef Compare July 26, 2026 07:31

mertcanaltin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I checked the guards in the base functions, and the window functions are covered too

and I looked fail test, this fail unrelated this pr

geeksilva97 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 27, 2026
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: Asroy Cristian Sitorus <asroycristiansitorus@gmail.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
mcollina force-pushed the fix-sqlite-close-during-callback branch from 822fbef to a477a99 Compare July 30, 2026 20:21
trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 4, 2026
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 4, 2026

Copy link
Copy Markdown
Collaborator

mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2026
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2026
nodejs-github-bot merged commit 5cef767 into nodejs:main Aug 4, 2026
70 checks passed

Copy link
Copy Markdown
Collaborator

Landed in 5cef767

mceachen added a commit to photostructure/node-sqlite that referenced this pull request Aug 9, 2026
Closing a database from inside a callback now reports "database cannot be
closed while in a callback" instead of "database cannot be closed inside a
user-defined function callback", the wording upstream adopted in
nodejs/node#64743. The error code (ERR_INVALID_STATE) is unchanged, so only
tests matching the old string are affected.

The upstream test that pins this message, test-sqlite-udf-close.js, had been
downloaded to test/upstream/ but never adapted into test/node-compat/, so its
four cases never ran. Generating it required making sync-node-tests.ts run its
sync only when invoked directly -- it already exported adaptTest() for reuse,
but importing the module kicked off a full network sync.
nodejs-github-bot pushed a commit that referenced this pull request Aug 11, 2026
Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
PR-URL: #65090
Refs: #64743
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Co-authored-by: Asroy Cristian Sitorus <asroycristiansitorus@gmail.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64743
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
PR-URL: #65090
Refs: #64743
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
PR-URL: #65090
Refs: #64743
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
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

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL