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

Verbose doesn't work with this library, it never did #113

Closed
mmghv opened this issue Apr 27, 2020 · 7 comments
Closed

Verbose doesn't work with this library, it never did #113

mmghv opened this issue Apr 27, 2020 · 7 comments

Comments

@mmghv
Copy link

mmghv commented Apr 27, 2020

I was never able to make verbose work with this library, consider the following example :

const sqlite3 = require('sqlite3');
const { open } = require('sqlite');
sqlite3.verbose();

(async () => {
  const db = await open({
    filename: ':memory:',
    driver: sqlite3.Database
  });

  db.run('select * from non_existent_table').catch(err => {
    console.log('promise rejected ...')
    throw err;
  });
})()

It's a very basic example, but the error throws doesn't have any trace info :

$ node app
promise rejected ...
(node:14036) UnhandledPromiseRejectionWarning: Error: SQLITE_ERROR: no such table: non_existent_table
(node:14036) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14036) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I first thought it was a bug, I forked the repo and tried to solve it, but it turned out it's not possible from this library because node-sqlite3 adds the trace info by catching an error you should throw, and throwing it instead of reject() causes the promise to never reject because an error thrown in an async callback cannot be caught by the promise.

I then sent an issue and a PR to fix it in node-sqlite3 repo.

I opened this issue here for anyone trying to figure out why it's not working with node-sqlite, please keep it open until the problem is fixed in the other repo, if it's not accepted there then update the docs so no one loses his mind trying to figure out the problem.

@mmghv
Copy link
Author

mmghv commented Apr 28, 2020

PR is merged, will be available in version 5.0.0 of node-sqlite3, will close the issue once it's released.

@theogravity
Copy link
Collaborator

Closing as v5 of node-sqlite3 is out. Thank you for the research and contrib!

@mmghv
Copy link
Author

mmghv commented May 2, 2020

It's not tagged yet, latest release still is 4.2.0

@theogravity
Copy link
Collaborator

ok, reopening

@theogravity theogravity reopened this May 6, 2020
@mmghv
Copy link
Author

mmghv commented Jul 1, 2020

v5.0.0 of node-sqlite3 is now released.

@mmghv mmghv closed this as completed Jul 1, 2020
@patarapolw
Copy link

v5.0.0 of node-sqlite3 is now released.

You really should explicitly say in README.md that node-sqlite supports v5.

@theogravity
Copy link
Collaborator

theogravity commented Jan 10, 2021

v5.0.0 of node-sqlite3 is now released.

You really should explicitly say in README.md that node-sqlite supports v5.

Not sure why this is important? Unless there's a v6 and there's some incompat issue that can't be addressed. So far the recent versions of sqlite3 haven't had bc issues that I'd figure most people will generally use the latest version of sqlite3.

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

No branches or pull requests

3 participants