WiseLibs / better-sqlite3

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

Bug: `iterate()` cannot contain `async/await` calls as a rejected promise / rejected exception will not stop the iterator #1218

Closed titanism closed 3 days ago

titanism commented 3 days ago

If you have a statement like iterate() and inside you have await foo() and if this function throws an error (e.g. it's a Promise that rejects), then the rejection error will not bubble up and will not cause the iterate to end, nor would manually wrapping it with a try/catch and adding a break; in the catch block.

titanism commented 3 days ago

seemed to be a bug in my code

mceachen commented 2 days ago

Thanks for circling back!

Can you share what the bug was so others can avoid that pitfall?

titanism commented 2 days ago

My promise wasn't actually rejecting, it was logging the error to console instead of throwing it