Skip to content
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

Fix queued channel failure logic #436

Merged
merged 7 commits into from
Oct 17, 2024
Merged

Conversation

marcospassos
Copy link
Member

@marcospassos marcospassos commented Oct 17, 2024

Summary

The current implementation of the queued channel doesn't handle failures, and that went unnoticed before because the old event tracker service just dropped invalid events. Now, with the new service, the SDK has to do the dropping. This change caused downstream channels to report errors to the upstream channel, which wasn't happening before—so this issue surfaced.

Right now, when a message fails, the queue just stops processing until a new event comes in. Since errors aren't being handled, failed messages don't get dequeued, which causes the queue to get stuck and eventually fill up.

This PR fixes that by making sure failed messages are dequeued so the next ones can still be tried.

Also, when the channel was reinitialized, you had to manually call the flush to reenqueue the messages. If you tried to send a message, it would fail and tell you to flush first. Now, it’s been refactored, so if there are pending messages, they’ll automatically get reenqueued before the new message is sent.

Lastly, this PR also makes "Connection deliberately closed" errors retryable since it's part of the regular lifecycle. For example, if the SDK is unplugged while messages are still being sent, it will retry sending them once plugged back in.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@marcospassos marcospassos added the bug Something isn't working label Oct 17, 2024
Copy link

pkg-pr-new bot commented Oct 17, 2024

Open in Stackblitz

npm i https://pkg.pr.new/@croct/sdk@436

commit: 077619e

denis-rossati
denis-rossati previously approved these changes Oct 17, 2024
@denis-rossati denis-rossati dismissed their stale review October 17, 2024 15:30

missclicked

src/channel/queuedChannel.ts Outdated Show resolved Hide resolved
src/channel/queuedChannel.ts Outdated Show resolved Hide resolved
@marcospassos marcospassos requested a review from Fryuni October 17, 2024 17:44
Copy link

codeclimate bot commented Oct 17, 2024

Code Climate has analyzed commit 077619e and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 99.9% (0.0% change).

View more on Code Climate.

@marcospassos marcospassos merged commit cb8d2d8 into master Oct 17, 2024
7 checks passed
@marcospassos marcospassos deleted the queue-channel-failure-logic branch October 17, 2024 18:13
@denis-rossati denis-rossati mentioned this pull request Oct 17, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants