Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite: handle conflicting SQLite and JS errors #56787

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Jan 27, 2025

This commit adds support for the situation where SQLite is trying to report an error while JavaScript already has an exception pending.

Fixes: #56772

Opening this PR since there hasn't been a reply on #56773 yet.

@nodejs-github-bot 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 Jan 27, 2025
@Renegade334
Copy link
Contributor

As a probably worthless thought, the alternative way of handling double-dipped errors would be to use error.cause:

  • instead of saving a boolean state for "ignore next error", create and store the JS exception object for "attach this to next error"
  • keep the primary exception thrown back to V8 as the error originating in sqlite, but if a secondary exception object has been stored, then assign this to error.cause on the way up

@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 27, 2025

That's not a bad idea. I'd prefer to leave that for a followup though.

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 75.86207% with 28 lines in your changes missing coverage. Please review.

Project coverage is 89.16%. Comparing base (2bd5694) to head (f61def8).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 75.86% 6 Missing and 22 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56787      +/-   ##
==========================================
- Coverage   89.16%   89.16%   -0.01%     
==========================================
  Files         665      665              
  Lines      192602   192618      +16     
  Branches    37050    37054       +4     
==========================================
+ Hits       171732   171746      +14     
- Misses      13678    13685       +7     
+ Partials     7192     7187       -5     
Files with missing lines Coverage Δ
src/node_sqlite.h 70.00% <ø> (ø)
src/node_sqlite.cc 79.84% <75.86%> (+0.19%) ⬆️

... and 24 files with indirect coverage changes

@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2025
@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig marked this pull request as draft January 29, 2025 17:30
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 29, 2025
@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig marked this pull request as ready for review January 29, 2025 19:45
@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 29, 2025

This could use a review. It addresses a nasty bug where data could be accidentally lost.

@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 29, 2025

It might be worth having a @nodejs/sqlite team too.

@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 30, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 30, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed needs-ci PRs that need a full CI run. labels Jan 31, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jan 31, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/56787
✔  Done loading data for nodejs/node/pull/56787
----------------------------------- PR info ------------------------------------
Title      sqlite: handle conflicting SQLite and JS errors (#56787)
Author     Colin Ihrig <[email protected]> (@cjihrig)
Branch     cjihrig:dualing-errors -> nodejs:main
Labels     c++, author ready, commit-queue-squash, sqlite
Commits    2
 - sqlite: handle conflicting SQLite and JS errors
 - nit
Committers 1
 - cjihrig <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/56787
Fixes: https://github.com/nodejs/node/issues/56772
Reviewed-By: James M Snell <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/56787
Fixes: https://github.com/nodejs/node/issues/56772
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - nit
   ℹ  This PR was created on Mon, 27 Jan 2025 14:29:43 GMT
   ✔  Approvals: 1
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/56787#pullrequestreview-2582507369
   ✘  This PR needs to wait 66 more hours to land (or 0 hours if there is one more approval)
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-01-30T20:31:35Z: https://ci.nodejs.org/job/node-test-pull-request/64857/
- Querying data for job/node-test-pull-request/64857/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/13079812165

@cjihrig
Copy link
Contributor Author

cjihrig commented Feb 1, 2025

The push was to resolve a conflict.

This commit adds support for the situation where SQLite is
trying to report an error while JavaScript already has an
exception pending.

Fixes: nodejs#56772
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 2, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 2, 2025
@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Feb 2, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Feb 3, 2025
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/56787
✔  Done loading data for nodejs/node/pull/56787
----------------------------------- PR info ------------------------------------
Title      sqlite: handle conflicting SQLite and JS errors (#56787)
Author     Colin Ihrig <[email protected]> (@cjihrig)
Branch     cjihrig:dualing-errors -> nodejs:main
Labels     c++, author ready, commit-queue-squash, sqlite
Commits    1
 - sqlite: handle conflicting SQLite and JS errors
Committers 1
 - cjihrig <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/56787
Fixes: https://github.com/nodejs/node/issues/56772
Reviewed-By: James M Snell <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/56787
Fixes: https://github.com/nodejs/node/issues/56772
Reviewed-By: James M Snell <[email protected]>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - sqlite: handle conflicting SQLite and JS errors
   ℹ  This PR was created on Mon, 27 Jan 2025 14:29:43 GMT
   ✔  Approvals: 1
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/56787#pullrequestreview-2582507369
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2025-02-02T02:57:57Z: https://ci.nodejs.org/job/node-test-pull-request/64905/
- Querying data for job/node-test-pull-request/64905/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/13115731534

@cjihrig
Copy link
Contributor Author

cjihrig commented Feb 3, 2025

@jasnell would you mind refreshing your LGTM. I had to rebase this PR and now it can't land.

@cjihrig cjihrig requested review from targos and anonrig February 4, 2025 13:31
@cjihrig cjihrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Feb 4, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 4, 2025
@nodejs-github-bot nodejs-github-bot merged commit c4fb331 into nodejs:main Feb 4, 2025
65 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in c4fb331

@cjihrig cjihrig deleted the dualing-errors branch February 4, 2025 13:58
targos pushed a commit that referenced this pull request Feb 5, 2025
This commit adds support for the situation where SQLite is
trying to report an error while JavaScript already has an
exception pending.

Fixes: #56772
PR-URL: #56787
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
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 pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. sqlite Issues and PRs related to the SQLite subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite: custom function callback errors should be reported to sqlite API
5 participants