fix: add default error listeners - #3748
Closed
zfaustk wants to merge 1 commit into
Closed
Conversation
## Context - Principle: Client and Pool background errors should reach explicit observers without becoming uncaught exceptions by default. - Why: Unobserved EventEmitter error events can terminate the process even after operation-level errors have already been returned. ## Key Deltas - Error emitters: Client, native Client, and Pool had no default handler -> each instance absorbs only otherwise-unobserved error events; why: preserve process stability while retaining normal user listeners. Key refs: packages/pg/lib/client.js:53, packages/pg/lib/native/client.js:25, packages/pg-pool/index.js:69 - Regression coverage: error behavior was implicit -> public emit behavior covers both no-listener and user-listener cases; why: prove the same Error still reaches user code. Key refs: packages/pg/test/unit/client/configuration-tests.js:13, packages/pg/test/native/evented-api-tests.js:9, packages/pg-pool/test/events.js:10 - Pool guidance: documentation warned of an uncaught exception -> guidance explains the default listener and recommends explicit observation; why: align the documented contract with pg@9 behavior. Key refs: docs/pages/apis/pool.mdx:264, packages/pg-pool/README.md:242 ## Verification Result: passed
Collaborator
|
bad tests, wrong target branch. i’ll just do it when the time comes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
errorlistener to everyClient, native-backedClient, andPoolErrorobjectFixes #3630.
Why
Today an otherwise-unobserved background
errorevent throws through Node's EventEmitter and can terminate the process. The operation-specific errors have already been returned, so pg@9 can provide a safer default while applications that add anerrorlistener continue to observe and handle the same event.This intentionally changes the behavior of unobserved
errorevents and is scoped to the pg@9.0 milestone.Testing
packages/pg/test/unit/client/configuration-tests.js(13 checks passed)packages/pg-pool/test/events.jserror-listener cases (2 passed)Pool; actual JavaScript and native-backedClientconstructors verified with the sameErrorreaching a user listenernode --checkon all changed JavaScript files andgit diff --checkThe full
yarn testmatrix was not run locally. The remaining database-backed tests inpackages/pg-pool/test/events.jsrequire a PostgreSQL service and stopped withECONNREFUSEDin this environment; upstream CI covers the Node/PostgreSQL matrix and native libpq suite.Authorship
Implemented and tested with Codex assistance. No human-review claim is made.