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

Properly close PG query stream on error #1935

Merged
merged 1 commit into from Feb 24, 2017

Conversation

Projects
None yet
2 participants
@caseywebdev
Collaborator

caseywebdev commented Feb 23, 2017

Without calling close(), the queryStream will continue to execute a
query meaning there was no way to halt a long running query due to an
unrecoverable downstream error. I ran into this issue while streaming
IDs from a very large table as part of an ETL process. An error would
occur downstream in the transformation or loading step and I needed to
cancel the long-running extract stream, but there was no way to do so
and I'd eventually run out of connections in the pool.

This commit also handles the case when the non-callback version of
stream API was used and an exception was thrown. The issue was that the
promise was not reachable and therefore there was no way to add a
rejection handler. This resulted in an unavoidable Unhandled Promise Rejection error.

Properly close PG query stream on error
Without calling `close()`, the `queryStream` will continue to execute a
query meaning there was no way to halt a long running query due to an
unrecoverable downstream error. I ran into this issue while streaming
IDs from a very large table as part of an ETL process. An error would
occur downstream in the transformation or loading step and I needed to
cancel the long-running extract stream, but there was no way to do so
and I'd eventually run out of connections in the pool.

This commit also handles the case when the non-callback version of
stream API was used and an exception was thrown. The issue was that the
promise was not reachable and therefore there was no way to add a
rejection handler. This resulted in an unavoidable `Unhandled Promise
Rejection` error.

@tgriesser tgriesser merged commit 19ed460 into tgriesser:master Feb 24, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@tgriesser

This comment has been minimized.

Owner

tgriesser commented Feb 24, 2017

Awesome, thanks Casey! Will look to get this out soon

@caseywebdev

This comment has been minimized.

Collaborator

caseywebdev commented Feb 24, 2017

👍 you da man. I love this lib 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment