WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.37k stars 394 forks source link

issue with async? #1016

Closed lolopinto closed 1 year ago

lolopinto commented 1 year ago

sorry for the vague title here.

I know better-sqlite3 is a synchronous library. I had been using it fine and I upgraded from 7.x to 8.x and some tests started failing sporadically.

I can't quite narrow it down in a repo so it seems specific to what I'm doing. is there any thing that changed from 7.x to 8.x that may cause this? Have i been using this incorrectly all this time?

Help would be appreciated. thanks

the nature of the error I'm seeing is sqlite errors which are thrown are somehow lost at some point. I understand this is vague and not that helpful so just asking if you've seen something like that in the past

lolopinto commented 1 year ago

I was on version 7.4.1 for a long time and just finally updating.

Here's what i have noticed: The issue starts at 7.5.0 which is of course a while back. I checked a bunch of versions and all the 7.4.* ones keep working

Simplified version of what I'm doing is something like https://github.com/lolopinto/better-sqlite-example/blob/main/src/test.ts but alas can't repro for those

I looked at the changes after 7.4.6 https://github.com/WiseLibs/better-sqlite3/commits/master?after=7eeab2f6bb1b4a90b52b4af208aadc10db0517af+69&branch=master&qualified_name=refs%2Fheads%2Fmaster but none stood out to me since I'm not familiar with the codebase

mceachen commented 1 year ago

All your wrapper methods like this one don't need to be async. (If you're new to promises, know that every async method can result in extra GC load on the VM as it manages promise wrappers behind the scenes). That said, it shouldn't cause errors.

Without a specific error to go on, this isn't an actionable issue.

lolopinto commented 1 year ago

It's async because it's a wrapper around something that's hitting a postgres db via pg or sqlite via better-sqlite3.

Ok, will close for now if you can't think of anything that should break with async