fix(sdk): prevent canceled health checks from stranding probes - #83
Conversation
Greptile SummaryThis PR prevents cancellation from stranding a shared connection-health probe by making gate registration and producer startup atomic while restoring interruptibility for the producer and all waiters.
Confidence Score: 5/5The PR appears safe to merge; no outstanding correctness, security, or repository-rule violations were identified. The current implementation closes the registration/startup interruption window and keeps the detached producer interruptible, with focused regression coverage for both behaviors. The previous producer-interruptibility finding was manually resolved without explanation, and the current code and added test address its underlying concern.
|
| Filename | Overview |
|---|---|
| packages/core/sdk/src/executor.ts | Atomically registers and starts shared health probes while restoring interruption for producer execution and waiter suspension. |
| packages/core/sdk/src/connections.test.ts | Adds focused regression coverage for cancellation during gate startup and for interruptible detached probes releasing their entries. |
Sequence Diagram
sequenceDiagram
participant C as Health-check caller
participant G as In-flight probe gate
participant P as Detached producer
participant W as Peer caller
C->>G: Register deferred (masked)
C->>P: Fork immediately (masked startup)
C->>G: Await deferred (interruptible)
W->>G: Find and await deferred (interruptible)
P->>P: Run probe (interruptible)
P->>G: Complete deferred
P->>G: Remove gate entry
G-->>C: Return outcome if still waiting
G-->>W: Return shared outcome
Reviews (2): Last reviewed commit: "test(sdk): verify detached health probe ..." | Re-trigger Greptile
A canceled health request could register a shared probe and stop before starting its producer. Later checks waited on that abandoned entry, leaving the status unchecked and eventually returning a Worker error.
Protect registration and producer startup with
Effect.uninterruptibleMask; restore interruption for both creator and peer waits. Start the detached producer immediately. Concurrent checks still share work, and canceling one waiter does not cancel the probe.Validation: a deterministic SDK regression fails before the fix and passes afterward; all 913 SDK tests, package tsgo, and scoped oxlint/format checks pass. The selfhost browser reconnect scenario passes. Live Worker checks return HTTP 200 and persist healthy verdicts after cancellation. The attached test screenshot shows the connection turning healthy without a page reload.