TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.23k stars 816 forks source link

`db.close()` never finishes on a DB with invalid path #1617

Open bpasero opened 2 years ago

bpasero commented 2 years ago

Issue Summary

When calling db.close I would always expect the callback to be called.

Steps to Reproduce

const sqlite3 = require('sqlite3').verbose();

setTimeout(() => { }, 10000);

const promise = new Promise(resolve => {
    const db = new sqlite3.Database('/Users/bpasero/Desktop/node-sqlite3/notexist/vsce.db', error => {
        if (error) {
            console.log(error);
        }

        console.log("Trying to close...");
        db.close(() => {
            console.log("Closed");
            resolve();
        });
    });
});

promise.then(() => process.exit());

Run this and notice how it never succeeds closing the DB.

Version

5.0.8

Node.js Version

16.15.1

How did you install the library?

macOS ARM

bpasero commented 2 years ago

I am also happy to learn that I do not have to call close in case new sqlite3.Database has an error in the callback and then I can solve this issue without calling close if that is expected.