fix: reconnect to platform events websocket after connection drop#967
Draft
vdusek wants to merge 2 commits into
Draft
fix: reconnect to platform events websocket after connection drop#967vdusek wants to merge 2 commits into
vdusek wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #967 +/- ##
==========================================
+ Coverage 89.91% 89.98% +0.06%
==========================================
Files 49 49
Lines 3085 3095 +10
==========================================
+ Hits 2774 2785 +11
+ Misses 311 310 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
After the first successful connection, delegate to the default `websockets` transient/fatal classification instead of retrying every error. Log graceful and abnormal closes (with close code and reason) as well as reconnect success, and cover both close paths with parametrized tests.
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.
Description
ApifyEventManager._process_platform_messagesconnected to the platform events websocket exactly once. Any dropped connection raisedConnectionClosedErrorand permanently ended the processing task, while a graceful server-side close exited silently. In both cases, the Actor missed all subsequent platform events (MIGRATING,ABORTING,PERSIST_STATE) for the rest of the run.websocketsreconnect iterator, which re-establishes the connection after every drop or graceful close, with backoff on failed attempts. An abnormal drop is logged as a warning and a graceful close as info, both with the close code and reason, and a successful reconnect is logged as well.process_exceptioncallback keeps errors fatal before the first successful connection, soActor.initstill fails fast on a misconfigured URL instead of hanging. After the first connection, the defaultwebsocketsclassification decides which errors are transient and retried.__aexit__now cancels the processing task before closing the websocket. Otherwise, every clean shutdown would trigger a spurious reconnect attempt.🤖 Generated with Claude Code