Skip to content

Bound stalled remote connector snapshot reads - #847

Merged
kody-bot merged 1 commit into
mainfrom
cursor/fix-meta-diagnostic-timeouts-4834
Jul 22, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/fix-meta-diagnostic-timeouts-4834

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • bound remote connector snapshot RPCs to five seconds and evict timed-out pending cache entries
  • degrade capability-registry discovery per connector so one stalled connector cannot hide built-ins or healthy connector capabilities
  • return structured connector error status for timed-out snapshots
  • add regression coverage for shared pending calls, cache eviction/retry, status errors, and mixed healthy/stalled registries

Validation

  • npm run validate passed
  • unit: 327 files, 1,047 tests
  • Playwright: 17 tests
  • MCP E2E: 2 tests
  • format, lint, typecheck, primitives, and migrations passed
System recap β€” extends existing primitives (medium risk)

Mode: recap Β· Base: main @ 711d7885 Β· Head: 3b3857c5

Classification: extends β€” bounds remote-connector snapshot latency and makes capability discovery fail softly per connector.

Primitives touched

Primitive Group Impact
capability-registry assistant extends β€” preserves built-ins and healthy dynamic capabilities when one connector stalls
connector-ingress surfaces extends β€” snapshot RPC reads now have a five-second deadline
remote-connectors assistant extends β€” timed-out snapshots become structured connector errors and are evicted for retry

System map

Remote connector snapshot reads feed capability discovery; this change bounds that edge and isolates failures to the affected connector.

Legend: green = composes (wiring only) Β· amber = extended by this PR Β· red = new primitive Β· gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	connectorIngress["connector-ingress<br/>Remote connector ingress"]:::extended
	remoteConnectors["remote-connectors<br/>Remote connectors"]:::extended
	capabilityRegistry["capability-registry<br/>Capability registry"]:::extended
	connectorIngress -->|"snapshot RPC: 5-second deadline + retryable eviction"| remoteConnectors
	remoteConnectors -->|"per-connector snapshot or null fallback"| capabilityRegistry
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Invariants

Connector snapshots and cache keys remain user-scoped; fail-soft behavior never substitutes another user's connector data.

Open in WebΒ Open in CursorΒ 

Summary by CodeRabbit

  • Bug Fixes
    • Remote connector snapshot requests now time out instead of hanging indefinitely.
    • Stalled connectors are reported as unavailable while healthy connectors continue providing capabilities.
    • Timed-out snapshot requests can retry successfully on subsequent attempts.
    • Connector status now clearly reports snapshot timeout errors.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Remote connector snapshot retrieval now times out stalled requests, retries after timeout, reports timeout status, and isolates failed connectors during dynamic capability registry construction.

Changes

Remote connector snapshot resilience

Layer / File(s) Summary
Snapshot timeout and retry behavior
packages/worker/src/remote-connector/snapshot-cache.ts, packages/worker/src/remote-connector/snapshot-cache.node.test.ts
Snapshot fetching uses a 5-second timeout with a dedicated error, concurrent callers share the in-flight attempt, and subsequent calls retry after timeout. Stalled snapshots produce error status results.
Per-connector registry loading
packages/worker/src/mcp/capabilities/registry.ts, packages/worker/src/mcp/capabilities/registry.node.test.ts
Dynamic capability loading converts individual snapshot failures to null, preserving capabilities from healthy connector instances while excluding stalled ones.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CapabilityRegistry
  participant SnapshotCache
  participant RemoteConnector
  CapabilityRegistry->>SnapshotCache: load connector snapshots
  SnapshotCache->>RemoteConnector: request getSnapshot()
  alt snapshot resolves
    RemoteConnector-->>SnapshotCache: return snapshot
  else snapshot stalls
    SnapshotCache-->>CapabilityRegistry: return timeout failure
    CapabilityRegistry-->>CapabilityRegistry: exclude failed connector
  end
Loading

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly matches the main change: adding bounds to stalled remote connector snapshot reads.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-meta-diagnostic-timeouts-4834

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-bot
kody-bot marked this pull request as ready for review July 22, 2026 04:40
@github-actions

Copy link
Copy Markdown
Contributor

πŸ”Ž Preview deployed: https://kody-pr-847.kody-a99.workers.dev

Worker: kody-pr-847
D1: kody-pr-847-db
KV: kody-pr-847-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/worker/src/remote-connector/snapshot-cache.ts`:
- Around line 18-39: Update getSnapshotWithTimeout and its callers to prevent
repeated snapshot RPCs after a timeout: either propagate cancellation to the
in-flight getSnapshot operation or add a short timeout-specific
negative-cache/backoff window before allowing another lookup. Preserve normal
successful and null snapshot behavior, and ensure timed-out connector requests
cannot trigger an immediate fresh stub.getSnapshot call.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 90a88c6e-4935-4673-81ec-e8b4a0e09ce0

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 711d788 and 3b3857c.

πŸ“’ Files selected for processing (4)
  • packages/worker/src/mcp/capabilities/registry.node.test.ts
  • packages/worker/src/mcp/capabilities/registry.ts
  • packages/worker/src/remote-connector/snapshot-cache.node.test.ts
  • packages/worker/src/remote-connector/snapshot-cache.ts

Comment on lines +18 to +39
async function getSnapshotWithTimeout(input: {
instanceId: string
getSnapshot: () => Promise<RemoteConnectorSnapshot | null>
}) {
let timeoutId: ReturnType<typeof setTimeout> | undefined
try {
return await Promise.race([
input.getSnapshot(),
new Promise<never>((_resolve, reject) => {
timeoutId = setTimeout(
() =>
reject(new RemoteConnectorSnapshotTimeoutError(input.instanceId)),
remoteConnectorSnapshotTimeoutMs,
)
}),
])
} finally {
if (timeoutId !== undefined) {
clearTimeout(timeoutId)
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | πŸ—οΈ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect the pending-cache implementation to confirm eviction/backoff behavior on rejection.
sed -n '1,56p' packages/worker/src/remote-connector/snapshot-cache.ts

Repository: kentcdodds/kody

Length of output: 1836


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== snapshot-cache usage =="
rg -n "getSnapshotWithTimeout|remoteConnectorSnapshotCache|createRemoteConnectorSnapshotCacheKey|RemoteConnectorSnapshotTimeoutError" packages/worker/src -S

echo
echo "== PromiseLruCache definition =="
fd -a "published-package-cache.ts|package-registry" packages/worker/src
rg -n "class PromiseLruCache|PromiseLruCache" packages/worker/src -S

echo
echo "== snapshot-cache tests =="
fd -a "snapshot-cache" packages/worker/src test packages
rg -n "RemoteConnectorSnapshotTimeoutError|snapshot cache|getSnapshotWithTimeout|PromiseLruCache" packages/worker/src test packages -S

Repository: kentcdodds/kody

Length of output: 9327


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== packages/worker/src/package-registry/published-package-cache.ts =="
wc -l packages/worker/src/package-registry/published-package-cache.ts
sed -n '1,220p' packages/worker/src/package-registry/published-package-cache.ts

echo
echo "== packages/worker/src/remote-connector/snapshot-cache.ts =="
sed -n '1,160p' packages/worker/src/remote-connector/snapshot-cache.ts

echo
echo "== packages/worker/src/remote-connector/snapshot-cache.node.test.ts (relevant section) =="
sed -n '1,280p' packages/worker/src/remote-connector/snapshot-cache.node.test.ts

Repository: kentcdodds/kody

Length of output: 11628


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
p = Path('packages/worker/src/package-registry/published-package-cache.ts')
print(p.read_text())
PY

Repository: kentcdodds/kody

Length of output: 2336


Add backoff or cancellation for timed-out snapshot RPCs Timed-out entries are evicted, so a persistently stalled connector will start a fresh stub.getSnapshot() on each later lookup while the previous RPC can still remain open. Consider a short negative-cache/backoff window after timeout, or propagating cancellation into the DO call.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/remote-connector/snapshot-cache.ts` around lines 18 - 39,
Update getSnapshotWithTimeout and its callers to prevent repeated snapshot RPCs
after a timeout: either propagate cancellation to the in-flight getSnapshot
operation or add a short timeout-specific negative-cache/backoff window before
allowing another lookup. Preserve normal successful and null snapshot behavior,
and ensure timed-out connector requests cannot trigger an immediate fresh
stub.getSnapshot call.

@kody-bot
kody-bot merged commit 7fadc2c into main Jul 22, 2026
7 checks passed
@kody-bot
kody-bot deleted the cursor/fix-meta-diagnostic-timeouts-4834 branch July 22, 2026 04:50
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.

3 participants