Skip to content

fix(sdk): prevent canceled health checks from stranding probes - #83

Merged
aryasaatvik merged 2 commits into
devfrom
fix/health-probe-cancellation
Sep 6, 2026
Merged

fix(sdk): prevent canceled health checks from stranding probes#83
aryasaatvik merged 2 commits into
devfrom
fix/health-probe-cancellation

Conversation

@aryasaatvik

Copy link
Copy Markdown
Owner

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.

Connection becomes healthy after reconnect without a page reload

@aryasaatvik
aryasaatvik marked this pull request as ready for review September 6, 2026 09:37
@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown

Greptile Summary

This 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.

  • Starts the detached producer immediately after registering its shared deferred.
  • Restores interruption around both existing-probe waits and creator waits.
  • Adds deterministic coverage for cancellation during startup and producer interruption after timeout.

Confidence Score: 5/5

The 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.

Important Files Changed

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
Loading

Reviews (2): Last reviewed commit: "test(sdk): verify detached health probe ..." | Re-trigger Greptile

Comment thread packages/core/sdk/src/executor.ts
@aryasaatvik
aryasaatvik merged commit d778a81 into dev Sep 6, 2026
3 of 36 checks passed
@aryasaatvik
aryasaatvik deleted the fix/health-probe-cancellation branch September 6, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant