Skip to content

fix(connection): improve connection management #219

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

Merged
merged 6 commits into from
Feb 27, 2025

Conversation

danielebriggi
Copy link
Member

  • resolve the creation of two connections. The dynamic import of the connection modules delayed the initialization of the SQLiteCloudConnection object. Between the initialization of the Database object and the call to sql() method, the connection was not yet initialized
  • connection to the database and the commands are put in queue to ensure the connection to be ready (the socket connection is a background operation)
  • remove the implicit connection to the database in the sql() methods. We want the user be aware of the status of the connection (eg, due to open transactions)
  • enable TCP keep alive to be notified of the most of the cases of errors on the TCP socket

@danielebriggi danielebriggi self-assigned this Feb 25, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

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

Project coverage is 86.33%. Comparing base (717b862) to head (12c129f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/drivers/database.ts 76.84% 22 Missing ⚠️
src/drivers/connection-ws.ts 69.23% 4 Missing ⚠️
src/drivers/connection-tls.ts 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
- Coverage   87.28%   86.33%   -0.96%     
==========================================
  Files          11       11              
  Lines         975      973       -2     
  Branches      287      288       +1     
==========================================
- Hits          851      840      -11     
- Misses        124      133       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- resolve the creation of two connections. The dynamic import of the connection modules delayed the initialization of the SQLiteCloudConnection object. Between the initialization of the Database object and the call to sql() method, the connection was not yet initialized
- connection to the database and the commands are put in queue to ensure the connection to be ready (the socket connection is a background operation)
- remove the implicit connection to the database in the sql() methods. We want the user be aware of the status of the connection (eg, due to open transactions)
- enable TCP keep alive to be notified of the most of the cases of errors on the TCP socket
@danielebriggi
Copy link
Member Author

ref: sqlitecloud/docs#111

Copy link
Member

@Gioee Gioee left a comment

Choose a reason for hiding this comment

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

generally lgtm, the only important thing remained to do is to update examples

@danielebriggi danielebriggi requested a review from Gioee February 26, 2025 16:36
@danielebriggi danielebriggi merged commit d8105d8 into main Feb 27, 2025
29 checks passed
@danielebriggi danielebriggi deleted the fix-connection-errors branch February 27, 2025 08:55
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.

3 participants