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

fix(desktop): fix sqlite disconnect warning issue #1897

Merged
merged 2 commits into from
Mar 18, 2025
Merged

Conversation

ysfscream
Copy link
Member

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

When closing the application, an unhandled promise rejection occurs with error: SQLITE_MISUSE: Database handle is closed. This happens because the application attempts to close the database connection multiple times during the shutdown process, causing errors when trying to close an already closed connection.

Issue Number

What is the new behavior?

Added safeguards to prevent multiple database connection close attempts:

  1. Added a flag to track if connections have already been destroyed
  2. Enhanced the connection destroy function with proper error handling
  3. Modified app shutdown flow to avoid duplicate cleanup calls
  4. Improved error handling in database connection management

This prevents the unhandled promise rejection and ensures a clean application shutdown.

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

No special instructions needed. This fix addresses the database connection closure error without changing any application functionality.

Other information

The error occurred because both the window's close event handler and the app's window-all-closed event handler were attempting to close database connections, leading to the same connection being closed twice.

@ysfscream ysfscream added fix Fix bug or issues desktop MQTTX Desktop labels Mar 17, 2025
@ysfscream ysfscream added this to the v1.12.0 milestone Mar 17, 2025
@ysfscream ysfscream requested a review from Red-Asuka March 17, 2025 02:59
@ysfscream ysfscream self-assigned this Mar 17, 2025
@ysfscream ysfscream marked this pull request as ready for review March 17, 2025 03:14
@Red-Asuka Red-Asuka merged commit 23eabd6 into main Mar 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop MQTTX Desktop fix Fix bug or issues
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants