Skip to content

feat(retry-on-timeout): Implement retry on timeout when creating new client#3491

Closed
MathieuGuillet wants to merge 4 commits intobrianc:masterfrom
MathieuGuillet:patch-1
Closed

feat(retry-on-timeout): Implement retry on timeout when creating new client#3491
MathieuGuillet wants to merge 4 commits intobrianc:masterfrom
MathieuGuillet:patch-1

Conversation

@MathieuGuillet
Copy link
Copy Markdown

@MathieuGuillet MathieuGuillet commented Jun 17, 2025

Add new options and instructions to implement retries on timeout when the pool tries to create new client in the pool.

This will avoid to throw an error on the first timeout error if it can be recover in a given time.

Add new options and instructions to implement retry on timeout when the pool tries to create new client in the pool.
This will avoid to throw an error on the first timeout error if it can be recover in a given time.
@MathieuGuillet MathieuGuillet changed the title Implement retry on timeout when creating new client feat(retry-on-timeout): Implement retry on timeout when creating new client Jun 17, 2025
Comment thread packages/pg-pool/index.js Outdated
@charmander
Copy link
Copy Markdown
Collaborator

charmander commented Jun 17, 2025

I think library users should be able to achieve this by calling the relevant pool function repeatedly as long as it returns a specific type of error (which might be different types of errors according to different needs). You can write a module for that.

@MathieuGuillet
Copy link
Copy Markdown
Author

I think library users should be able to achieve this by calling the relevant pool function repeatedly as long as it returns a specific type of error (which might be different types of errors according to different needs). You can write a module for that.

I understand your suggestion, but we are using an ORM (TypeORM) and it does not allow to trick that point easily (we have to change the driver to achieve what you suggest).
I believe it would be reasonable for the connection pool to handle retrying failed connections, within a configurable limit, for a predefined set of error types.
I agree that limiting the retries to only timeout errors is too specific/restrictive. I can improve that by exposing a function in the configuration options to check if an error should trigger the retries (like in TypeORM config: toRetry: (err) => boolean)

What do you think @charmander ? Can I re-open this PR and improve the behavior as explained?

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

Successfully merging this pull request may close these issues.

2 participants