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

support throwing from response #56

Open
gsimko opened this issue Dec 21, 2024 · 0 comments
Open

support throwing from response #56

gsimko opened this issue Dec 21, 2024 · 0 comments

Comments

@gsimko
Copy link

gsimko commented Dec 21, 2024

It would be nice to support throwing errors from tracker.response. It's almost working today but the setTimeout() that surrounds the internals of the Promise in Tracker._handle puts the exception in the wrong context and hence it's not raised through the same stack as a regular db error is. I'm uncertain what's the purpose of that timeout is - would it be possible to remove it?

Use case: I have an array of objects that I want to respond with during mocking. Some of these are pg.DatabaseError objects, which would require some complicated orchestration with simulateError to emit at the right time - if at all doable.
For example I have test queries that fail on first attempt due to race conditions (using serializable transactions) and succeed on the second one. It's hard to describe such a scenario with the current API as the query/binding/etc is the same, the only difference is in which order they are called.

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

1 participant