Repository navigation
fix: retry lazy publisher init after a failed attempt #653
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,8 +110,14 @@ export abstract class AbstractSqsPublisher<MessagePayloadType extends object> | |
| if (!this.initPromise) { | ||
| this.initPromise = this.init() | ||
| } | ||
| await this.initPromise | ||
| this.initPromise = undefined | ||
| const initPromise = this.initPromise | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not caused by this PR, but it's close to it: in SQS, SNS and PubSub, Fine to leave it for a follow-up if you prefer. I just wanted to mention it since we're touching this code.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CarlosGamero How we would want
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question! I’d keep today’s behaviour: after close(), isInitted is false, so the next publish() just runs the lazy init again and sends. Rejecting would be a breaking change and isn’t related to this fix. With that in mind, the case I mentioned ends up almost the same as a normal re-init, so it’s low risk. The only small thing would be clearing initPromise in close() like AMQP already does, to keep the publishers consistent, but that’s optional and fine for a follow-up. Not a blocker for this PR 👍 |
||
| try { | ||
| await initPromise | ||
| } finally { | ||
| // Cleared on failure too, so the next publish retries the init instead of re-awaiting the | ||
| // same rejection. Only if still ours: a concurrent caller may already have started a retry. | ||
| if (this.initPromise === initPromise) this.initPromise = undefined | ||
| } | ||
| } | ||
|
|
||
| try { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.