Repository navigation
fix(sdks/ts): recover from inactive listener stream on heartbeat rejection - #4867
RealBhupesh wants to merge 1 commit into
Conversation
…ction When the engine loses a worker's ListenV2 stream but unary heartbeats still reach the server, the TypeScript SDK now detects consecutive FailedPrecondition rejections and re-establishes the listener. Workers are marked UNHEALTHY during reconnect, and /health returns 503 so orchestrators can restart stuck replicas. Fixes hatchet-dev#4824
|
@RealBhupesh is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for taking the time to open this pull request! ❤️ To keep our review queue focused, we only accept pull requests that are linked to an issue the Hatchet team has already triaged, labelled We couldn't find a linked issue that's both accepted and assigned to you, so we're closing this PR for now. This isn't a reflection of the quality of your work — it just helps us make sure effort goes into changes we're ready to merge, and that two people don't unknowingly build the same thing. What to do next:
|
|
No concerns with the implementation here — this was closed automatically by the Status: implementation is complete on @ubajwa-sketch — your verbal go-ahead is noted; we just need the formal triage step so the bot stops closing it. Thanks for offering to test against your repro once review starts. |
Greptile SummaryThe PR adds TypeScript worker self-recovery when heartbeats indicate that the ListenV2 stream is inactive and makes worker health affect the HTTP health-check status.
Confidence Score: 4/5The reconnect-attempt cap must be corrected before merging because repeated successful recoveries can continue indefinitely instead of stopping after the configured limit. The new recovery path resets its attempt counter after every successful listener establishment, so repeated inactive streams never reach the advertised failure threshold; the SDK release metadata requirement is also unmet. Files Needing Attention: sdks/typescript/src/clients/dispatcher/action-listener.ts and the TypeScript SDK release metadata Reviews (1): Last reviewed commit: "fix(sdks/ts): recover from inactive list..." | Re-trigger Greptile |
|
|
||
| await this.heartbeat.start(); | ||
| await this.heartbeat.start(() => this.handleStreamInactive()); | ||
| this.streamInactiveReconnects = 0; |
There was a problem hiding this comment.
Reconnect cap never accumulates
When the listener repeatedly becomes inactive after successful reconnections, getListenClient() resets streamInactiveReconnects before the next failure, so the counter never exceeds the configured limit and the worker reconnects indefinitely instead of surfacing the terminal error.
| this.streamInactiveReconnects = 0; |
| import { | ||
| isListenerReconnectAbort, | ||
| isListenerShutdownAbort, | ||
| LISTENER_RECONNECT_REASON, | ||
| LISTENER_SHUTDOWN_REASON, | ||
| } from './listener-abort'; | ||
| import { WorkerStatus, workerStatus } from '@hatchet/v1/client/worker/health-server'; | ||
|
|
||
| const DEFAULT_ACTION_LISTENER_RETRY_INTERVAL = 5000; // milliseconds | ||
| const DEFAULT_ACTION_LISTENER_RETRY_COUNT = 20; | ||
| const DEFAULT_STREAM_INACTIVE_RECONNECT_COUNT = 10; |
There was a problem hiding this comment.
This changes published TypeScript SDK recovery and health behavior without the required version bump and changelog entry, leaving release tooling and consumers without a versioned record of the change.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Fixes #4824 — when the engine loses a worker's ListenV2 stream but unary heartbeats still reach the server, the TypeScript SDK now self-heals instead of entering a permanent zombie state.
FailedPreconditionrejections whose message isworker stream is not active; after 3 consecutive failures, posts astream_inactiveIPC messageActionListeneraborts the current ListenV2 with a reconnect-specific reason (distinct from shutdown), stops the heartbeat thread, and the existingactions()loop re-establishes viagetListenClient()/listenV2. Capped at 10 reconnects with 3s backoffUNHEALTHYduring reconnect;/healthreturns 503 when unhealthy (also fixes TypeScript SDK: worker /health always returns HTTP 200, even when UNHEALTHY — breaks Kubernetes liveness probes #4823 for K8shttpGetprobes)No engine changes.
Test plan
isWorkerStreamInactiveErrorunit testsMade with Cursor