Repository navigation
fix(cli): Don't attach local run or serve to a non-receiver on the port - #2433
Merged
Merged
Conversation
Any HTTP reply to /health counted as an existing receiver, so a port held by something like `python -m http.server` made `local run` and `local serve` "connect" to it and lose every event. A receiver is now recognized by the X-Powered-By header that Local and Spotlight's sidecar both send. A plain `local run` on a port held by anything else captures on a free port and says so; an explicit --port and `local serve` fail with a port-in-use error. Co-Authored-By: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
MathurAditya724
approved these changes
Nov 19, 2026
MathurAditya724
left a comment
Member
There was a problem hiding this comment.
Reviewed and retested with main after #2432. Typecheck, lint and the full workspace suite pass. Independent real-HTTP health probes cover seven combinations of foreign/receiver/daemon headers and success/error statuses. Real CLI checks confirm that run and serve fail with exit 21 on an explicit foreign port, while a foreign listener on the default port causes run to capture successfully on another port without posting to the foreign server. Identified sidecars remain attachable on HTTP 503. No actionable findings.
This was referenced Nov 19, 2026
MathurAditya724
added a commit
that referenced
this pull request
Nov 20, 2026
…2437) Follow-up to #2433. #2433 stopped `local run` and `local serve` from attaching to an HTTP server that isn't a Local receiver. But if whatever holds the port never sends an HTTP reply to `/health`, the probe still read that as "nothing here". That covers a silent listener, a slow one, a non-HTTP service or a TLS server. The bind then failed, the CLI attached anyway, and events were lost. Now only a refused connection means the port is free. Anything else counts as held by another process, so it goes through the same free-port fallback or error that #2433 added. Also in this PR: - The probe doesn't follow redirects anymore, so a `/health` that redirects to a real receiver no longer passes for one. - If something takes the port between the probe and the bind, `run` probes again instead of attaching blindly. - `--verify` uses the same "is held by another process" wording. - A `local serve` from CLI 0.35–0.40 doesn't send the receiver header, so it now counts as another process. Upgrade it to attach to it. **Before**, with a silent TCP listener on 8969: ``` $ sentry local run -- node app.js [info] No server detected, starting one in the background... [warn] Port 8969 is in use; attaching to it instead ``` Every event was lost. **After:** ``` $ sentry local run -- node app.js [info] Port 8969 is held by another process, so this run listens on port 35735 instead. SDKs that hard-code 8969 won't reach it; make sure they read SENTRY_SPOTLIGHT. $ sentry local run --port 18771 -- node app.js Error: Port 18771 is already in use by another process. Stop it, or pass --port to use a different port. ``` <!-- junior-request-attribution:start --> via @MathurAditya724. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aa01bd99b1c38568d947d97979a3a64cb --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Aa01bd99b1c38568d947d97979a3a64cb) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aa01bd99b1c38568d947d97979a3a64cb/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com>
This branch was successfully deployed
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.
If any HTTP server was on the Local port,
local runandlocal servetreated it as a Local receiver. They attached to it, and every event was lost without a word.Now a server only counts as a receiver if its
/healthsends theX-Powered-By: spotlight-by-sentryheader. Local and Spotlight's own sidecar both send it, even on errors. If anything else holds the port:local runcaptures on a free port and says so, the same way it does when the Local daemon holds the portlocal run --port Nandlocal servestop with a port-in-use error that names the portAttaching to the daemon, a
local servein another terminal, or the Spotlight sidecar works the same as before.Before, with
python -m http.server 8969running:local serveprinted the same, then exited 0.After:
local serveexits non-zero here, and so doeslocal run --port Nwhen N is held.via @MathurAditya724.
--
View Session [Sentry]