porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

add error handler to subscribe #785

Closed Louis-Tian closed 2 months ago

Louis-Tian commented 6 months ago

Related to https://github.com/porsager/postgres/issues/757.

Expose a error handler on the subscribe function so any error happened while streaming replica can be handled in user space.

mattbishop commented 6 months ago

Can you update the Typescript definition to include this please?

Louis-Tian commented 6 months ago

@mattbishop done. Happy to add a test case for it as well.

But I am not sure what would be best way to go about it. Specifically what's the best way to stub the stream in test to force an error?

porsager commented 5 months ago

@Louis-Tian I have some other tests where I just terminate the backend. Perhaps that's a way forward?

Louis-Tian commented 5 months ago

@porsager That's kind of what I am doing in the error handler anyway so that will work for me. Just think it would be better to let the user to decide to what do? But if there is other things that require a direct termination then I guess it make perfect sense to just leverage on that.

porsager commented 2 months ago

This already seems to be merged, so I don't understand why the PR is still open.