Skip to content

fix(upstream): hard-kill launcher group when Stop gives up (#1614) - #1629

Merged
Dumbris merged 2 commits into
mainfrom
fix/1614-launcher-teardown
Oct 16, 2026
Merged

Dumbris merged 2 commits into
mainfrom
fix/1614-launcher-teardown

Conversation

@Dumbris

@Dumbris Dumbris commented Oct 16, 2026

Copy link
Copy Markdown
Member

Summary

Issue #1614: a launcher that backgrounds a long-lived descendant and exits first could leave that descendant running after teardown.

Finding: on current main the launcher layer already covers the common case (Spec 116 PR4 review round 6 keeps the exited leader unreaped while a group member runs, so Stop still signals the group). The remaining gap is Stop giving up early (expired context) with the group still up. stopLauncher and the wait-for-url failure cleanup now call handle.Kill() after a Stop error. Kill signals the recorded group only while the leader is unreaped, so a reused group number is never hit.

Adds TestStopLauncher_LeaderExitedFirst_KillsDescendant (TERM-immune backgrounded child, launcher exits first, expired Stop context). Note: this test already passed before the change on main (the launcher layer handles it), so it is a regression guard rather than a failing-first test.

Tests

  • go test -race ./internal/upstream/core ./internal/upstream/launcher passes
  • GOOS=windows go vet on both packages passes
  • golangci-lint (bare and --build-tags server): only a pre-existing govet finding in client_secret_test.go

Closes #1614

…ndant is not orphaned (#1614)

stopLauncher and the wait-for-url cleanup call handle.Kill() after a Stop
error. Handle.Kill signals the recorded group only while the leader is
unreaped, so a reused group number is never hit. Adds a regression test for a
launcher that backgrounds a TERM-immune child and exits first.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ecca24f
Status: ✅  Deploy successful!
Preview URL: https://ebdaadf8.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-1614-launcher-teardown.mcpproxy-docs.pages.dev

View logs

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/1614-launcher-teardown

Available Artifacts

  • archive-darwin-amd64 (31 MB)
  • archive-darwin-arm64 (28 MB)
  • archive-linux-amd64 (19 MB)
  • archive-linux-arm64 (17 MB)
  • archive-windows-amd64 (31 MB)
  • archive-windows-arm64 (28 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (27 MB)
  • installer-dmg-darwin-arm64 (25 MB)
  • smart-mcp-proxymcpproxy-goJRISBI.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 38895429277 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris
Dumbris merged commit 86b6ac7 into main Oct 16, 2026
48 checks passed
Dumbris added a commit that referenced this pull request Oct 17, 2026
…nts (#1637)

## Root cause
`TestConfigWatcher_ExternalRevertToLastSelfWriteReloads` flaked on
macOS-15 runners (#1629, #1634). It is not a self-write-marker bug: with
debug instrumentation under CPU load (reproduced ~1 in 100-250 runs
locally on macOS), the final external revert to byte-identical A
produced **no fsnotify event at all** after B's reload, so no debounce
fired and the config stayed on B. fsnotify's kqueue backend can drop the
event for a rename-over that follows a recently handled one. This is a
real production hole (an external edit can be silently missed until
restart), not only a test timing issue.

## Fix
`runConfigWatchLoop` now also polls (2s) and compares file bytes with
the last evaluated content; on a difference it arms the normal debounce
-> `reloadFromDiskIfChanged` path, so self-write suppression is
unchanged. The poll does not re-arm a pending debounce.

## Tests
- New `TestConfigWatcher_PollRecoversMissedFsEvent` deterministically
simulates total event loss (watch on an unrelated dir) and fails without
the poll.
- Before: 2 failures in ~120 runs, 1 in 250 (12 CPU spinners + 10
parallel test processes). After: 0 failures in 100 runs of the whole
`TestConfigWatcher_` suite under the same load, plus 20 clean sequential
`-race` runs.
- golangci-lint (bare and `--build-tags server`) on `internal/runtime`:
only a pre-existing `reflect.Ptr` inline finding in `event_bus.go`,
untouched here.
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.

Launcher teardown leaves a descendant running when the launcher process exits first

2 participants