fix: lazy retry, handle cases, drop async-retry#1218
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Postgres transaction setup retries to remove the async-retry dependency and avoid retry machinery overhead on the common success path, while expanding the set of retryable transaction-setup failures.
Changes:
- Replace
async-retrywith an inlined retry loop (bounded attempts + total time budget) for transaction setup inPgTenantConnection. - Add retry handling for additional transaction-setup failure modes (connection-state and broken-client/socket-level errors).
- Remove
async-retryand its type dependencies frompackage.json/package-lock.json, and add targeted unit tests for the new behavior.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/internal/database/pg-connection.ts | Replaces async-retry with a custom retry loop and adds retry classification for additional transient setup errors. |
| src/internal/database/pg-connection.test.ts | Adds unit tests to validate the new retry behavior and the “no timers on success” performance goal. |
| package.json | Drops async-retry and @types/async-retry dependencies. |
| package-lock.json | Removes async-retry (and related types) from the lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 29005394843Coverage increased (+0.02%) to 79.254%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
fenos
approved these changes
Jul 9, 2026
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
2b81c2f to
8dcf603
Compare
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.
What kind of change does this PR introduce?
Refactor for performance
What is the current behavior?
Currently every transaction pays the price of async retry machinery. Machinery should be bolt on when it fails.
What is the new behavior?
Replace async-retry with a for loop, which is cheaper (no operation building, no options allocation, no promise, etc.), easier to maintain (no dependency), faster (no next tick).
Additional context
Start retrying connection state and broken client errors as well.
It's around 7x CPU, 6x GC friendly on success and 1.5x CPU, 3x GC friendly on retries.