-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
Node-API crash with unhandled promise after SQLITE_CANTOPEN #1646
Comments
I also ran into this error, however, it is not a bug. You simply need to handle errors that can occur during database opening by adding a callback to your const mode = sqlite3.OPEN_READWRITE | sqlite3.OPEN_FULLMUTEX; // Or whatever you want
const db = await new Promise((resolve, reject) => {
const db_ = new sqlite3.Database('xxx/x.db', mode, err => {
if (err) {
reject(err);
} else {
resolve(db_);
}
});
}); |
I also handled the error the same way. The provided example is a contrived example to trigger the issue. It's about the error handling in the C++ code and not the JavaScript code, it shouldn't be possible to raise a Node-API C++ exception from Node.js. |
Oh okay, fair enough, I stand corrected 🙂 |
Issue Summary
The following crash occurs when a promise doesn't resolve and the SQLite file cannot be opened:
xxx/x.db
but notx.db
Steps to Reproduce
index.js
andindex.test.js
:index.js:
index.test.js:
Version
5.1.2
Node.js Version
18.11.0
How did you install the library?
Via npm on macOS 13.0 Beta (22A5373b) arm64
The text was updated successfully, but these errors were encountered: