Repository navigation
fix(macos): quit the running tray in the PKG preinstall - #2024
Merged
Merged
Conversation
After `brew upgrade --cask mcpproxy` the menu bar showed two MCPProxy icons, and a manual PKG upgrade left the old version running (#957). The package's postinstall only ran `open -a`; the quit-first step added for #957 lived in packaging/macos/postinstall.sh, which no package shipped, and matched a process path the installed app never has (`MCPProxy.app/...` while the payload installs `mcpproxy.app`). The package now ships scripts/preinstall.sh, which quits the tray before its bundle is replaced: SIGTERM (the tray routes it through its normal quit path and stops the core), then SIGKILL after 8s, scoped to the console user, never failing the install. The match is case-insensitive and anchored on `.app/Contents/MacOS/mcpproxy`, so it covers every bundle spelling and leaves the core to the tray. The unshipped duplicate script is removed. scripts/preinstall.test.sh runs the quit step against real processes started from fake bundles and checks that create-pkg.sh ships the script; it runs in unit-tests.yml. Closes #2016
Deploying mcpproxy-docs with
|
| Latest commit: |
941be64
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c109101e.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-issue-2016-investigat.mcpproxy-docs.pages.dev |
Review of the preinstall quit step found two real problems. `pgrep -f` also searches arguments, so the unanchored pattern would have signalled any process that merely named the tray's path (for example `less /Applications/mcpproxy.app/Contents/MacOS/MCPProxy`). The pattern is now anchored at the start of the command line. A bundle under a directory with a space in its name is no longer matched; the package installs to /Applications. The self-test deleted its temp dir in an EXIT trap without checking that mktemp had succeeded; with an unusable TMPDIR that resolved to the caller's working directory. The test now stops before the trap exists. Fixtures are sleep(1) started under the fixture's name (`exec -a`), so their command lines start with the bundle path like a real tray's, and a bystander process that only names the tray path must survive.
The self-test passed its temp dir to pgrep/pkill unescaped. Those take regular expressions, so the "." in a mktemp name could match a process under a different directory, and the cleanup trap could have killed it. The path is now escaped and the cleanup match is anchored. The bystander fixture also left a `sleep 600` child behind after each run; it is now a single cat(1) blocked on a FIFO.
Dumbris
enabled auto-merge (squash)
November 24, 2026 05:26
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 45333148155 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Description
Closes #2016
After
brew upgrade --cask mcpproxythe menu bar showed two MCPProxy icons. A manual PKG upgrade had the related problem from #957: the old version kept running.Cause. The package's
postinstallonly ranopen -a. The quit-first step written for #957 lived inpackaging/macos/postinstall.sh, which no package ever shipped (create-pkg.shcopiesscripts/postinstall.sh). That script's process match was also wrong for the installed app: it looked forMCPProxy.app/Contents/MacOS/MCPProxy, while the payload installsmcpproxy.appandpgrep -fis case-sensitive.Fix. The package now ships
scripts/preinstall.sh, which quits the running tray before its bundle is replaced:-U <uid>), so other sessions on a shared Mac are left alone..app/Contents/MacOS/mcpproxy, so it coversmcpproxy.app,MCPProxy.appand the legacy Go tray, and does not match the core atContents/Resources/bin/mcpproxy.postinstallis unchanged apart from a comment: it still sets up the CLI and launches the new tray.Decisions a reviewer may question
pgrep -falso searches arguments, so the pattern is anchored to the start of the command line. A bundle under a directory with a space in its name is therefore not matched.quit. The [Bug]: old version App still after upgrade #957 script tried it first. Sent from the installer's root context it depends on an Automation consent the user never gave and can stall the install, and SIGTERM already reaches the same quit path.scripts/postinstall.sh.Not in this PR
smart-mcp-proxy/homebrew-mcpproxy) should also getquit: "com.smartmcpproxy.mcpproxy"in itsuninstallstanza, so the tray quits before Homebrew'spkgutil:step deletes the bundle. This PR fixes the upgrade without it.Testing
scripts/preinstall.test.shstarts real processes under fake bundle paths in a temp dir and runs the script's quit step against them (matches are confined to the temp dir, so a real tray on the machine is untouched). It covers: nothing running, the shipped lowercase layout, the other spellings, a tray that ignores SIGTERM, and three things that must survive: the core, a longer executable name, and a process that only names the tray path as an argument. It also checks thatcreate-pkg.shships the script. 15/15 pass on macOS (bash 3.2) and in an Ubuntu 24.04 container; with the old case-sensitive match restored 4 checks fail, and with the anchor removed 1 fails. It runs as the newmacOS PKG Preinstalljob inunit-tests.yml.Checked locally with real packages on macOS (arm64, installed tray 0.75.0):
pkgbuildfrom the installed, notarized 0.75.0 bundle and the scripts exactly ascreate-pkg.shcopies them. Afterpkgutil --expand,PackageInforegisters bothpreinstallandpostinstall, and both are byte-identical to the sources.preinstalland a dummy payload and installed it withinstaller -target CurrentUserHomeDirectory, so PackageKit itself ran the script against the live 0.75.0 tray./var/log/install.log:open -athen started exactly one tray.Not tested: the full signed product pkg installed as root, and
brew upgrade(both need the release signing identity and sudo). In the user-domain run the script ran as the user, not root. One observation for the RC check: the old core took about 30 seconds to finish its own shutdown after the tray quit, so the new tray can start while it is still exiting; that case is left to the existing stale-core supersede (Spec 092). The Go and Swift changes are comments only; I rango build ./internal/launch/and no other suites.