fix: stabilize SDK bridge lifecycle, port reuse, and shutdown guards#27
Open
wbugitlab1 wants to merge 8 commits into
Open
fix: stabilize SDK bridge lifecycle, port reuse, and shutdown guards#27wbugitlab1 wants to merge 8 commits into
wbugitlab1 wants to merge 8 commits into
Conversation
Session: Cursor API root cause Project: composer-api Branch: fix-cursor-api-lifecycle Workspace: b6de4c1d-a4b3-4b67-aaf1-053ecb648b00 Files: 12 changed Auto-saved before the worktree was removed so no work is lost. Restore it as a branch with `git branch <name> <this-commit>`.
Await SDK disposal, terminate orphaned bridge processes, and recycle retryable stale bridge state before response output. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Document the combined lifecycle and stable bridge-port installation, record the process-wide recycle trade-off, and remove generated XCTest metadata artifacts. Co-authored-by: Copilot App <[email protected]>
Port-preference code and tests from stabilize-bridge-port are already present via febf69b; this ancestry-only merge records branch history without reapplying changes. Co-authored-by: Copilot App <[email protected]>
Lifecycle bridge shutdown, harness, and script changes from fix-cursor-api-lifecycle are already present via 9d71542; this ancestry-only merge records branch history without reapplying changes. Co-authored-by: Copilot App <[email protected]>
Exclude bridge_shutting_down from pre-output recovery, refuse endpoint launches after shutdown, and always verify bridge health before reuse.
wbugitlab1
force-pushed
the
pr/sdk-bridge-lifecycle
branch
from
July 12, 2026 15:54
d69ae71 to
5a0bb71
Compare
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.
Summary
Fixes recurring local Responses API failures caused by stale or incompletely disposed Cursor SDK bridge state in the packaged macOS app.
Symbol.asyncDisposefor cached agents, parent-PID watchdog, bounded drain (CURSOR_SDK_BRIDGE_SHUTDOWN_TIMEOUT_MS)503/cursor_sdk_unavailablefailuresshutdown(), no retry onbridge_shutting_down, health check before bridge reuse8792–8892) instead of rescanning on every launchProblem
After repeated use, the owned bridge process could retain poisoned SDK state. Restarts picked variable bridge ports, shutdown did not always wait for in-flight agent disposal, and shutdown-time
503responses could still trigger bridge recycle — leading to flaky/v1/responsescalls until a full app restart.Test plan
npm test— 236/236 passed (includes 65 bridge lifecycle tests)npm run typecheckswift build -c releasefrommacos/CursorAPIConnectivityCheckTests,CursorSDKBridgeServerTests) — requires full Xcode toolchainpackage-app.sh --development) and installed to/Applications/healthverified after install (port 8793)Notes
@cursor/sdkremains at 1.0.13cursor/f82fde30(now integrated and branch deleted)