Repository navigation
fix: skip dead-pid proxy-origin records in MCP shell origin resolution (#405) - #516
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
#405, split from #514 fix 1) A crashed/killed proxy leaves its JSON instance record behind naming a port nothing listens on; MCP shells then dial the dead origin forever. resolveProxyOrigin now checks pid liveness (kill-0) on JSON records before trusting them and falls back to the default origin with a one-time stderr note. pid 0 (foreign record without a liveness claim) and legacy plain-URL pointers keep the old trust.
Contributor
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-516Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr516.tgz
npm install -g packageThis comment is automatically updated on each push. |
4 tasks done
Owner
Author
[bot] 🏷 Done — PR: #522 Triage verdict
Pre-flight
Notes (accepted limitations, report-only)
No version bump, no lockfile change. Merge is yours — I can't merge PRs. |
3 tasks
Owner
Author
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.
Split from #514 (fix 1 of 5, the only part still a gap on master — see review there). Completes the read-side (零验活) half of #403 — the piece the instance registry (#419) did not cover. (Note: #514's body cited #405, but that issue is the unrelated ACP_PASSTHROUGH observability bug; no auto-close intended.)
Problem
resolveProxyOrigin()(src/mcp.ts) resolves env → instance file → default with no liveness check. When a proxy crashes or is killed, its JSON instance record stays behind naming a port nothing listens on — spawned MCP shells then dial the dead origin forever, and every tool call fails until the host client is restarted (or a new proxy happens to bind that exact port).Fix
Rebuilt on the
src/instance.tsprimitives (#394/#403/#417) rather than the HTTP-probe chain from #514:isPidAlive, kill-0 — synchronous, no network on the hot path) is trusted as today.http://127.0.0.1:8787, where a replacement proxy binds) with a one-time stderr note suggestingBILI_MCP_PROXYif the proxy runs elsewhere. Self-healing: the next tool call re-resolves, so a restarted proxy on the default port is picked up with no shell restart.pid: 0(record makes no liveness claim, foreign writer) and legacy plain-URL pointers keep the old trust semantics.Why pid-check instead of #514's
/__bili/healthprobe: the JSON record already carries the writer's pid, the check is synchronous (probe would have to become async + cached), and it exactly matches how the launcher attach and plugin-install already gate on the same file.Tests
tests/instance-governance.test.ts: dead-pid JSON record → default origin; live pid → record origin; pid 0 → trusted.
Pre-flight
typecheck ✅ · full suite 1031/1033 (2 known plugin-agent env fails, unchanged baseline) · build ✅