Repository navigation
fix: resolve the port shorthand through localhost, not 127.0.0.1 - #31
Merged
Merged
Conversation
`switchboard add app 3000` recorded 127.0.0.1:3000. That is one of two addresses meaning this machine, and a server listening on ::1 does not answer on it. Node dev servers commonly bind IPv6 loopback only, so the route was dead from the moment it was added. The failure gave nothing to go on. The app plainly worked at localhost:3000, because browsers try both families, while `ls` said `down` — the same word it uses for a server that is not running, so the one diagnostic pointed away from the cause. The shorthand is now localhost:<port>. Go's dialer tries both families for a name and takes whichever answers (RFC 6555), which is what the browser was doing all along. Verified against a live IPv6-only server: 127.0.0.1:3000 refused, localhost:3000 connected to [::1]:3000. Nothing on disk changes. `port = 3000` stays exactly as written; only the address derived from it moves, so every existing route gets this without anyone editing a config. `ls` and `doctor` come along for free, since both probe through UpstreamAddr. --upstream is untouched. Naming an address is how you say you meant that address. Only the outbound dial to the user's own dev server is affected. Every socket Switchboard listens on stays pinned to 127.0.0.1. No test binds a real IPv6 socket: CI runners cannot be assumed to have IPv6, and a test that skips itself there would give the least coverage exactly where regressions are likeliest. TestUpstreamAddr pins the returned string instead, which is what a regression would change. Closes #28
Merged
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.
Closes #28.
switchboard add app 3000recorded127.0.0.1:3000. That is one of two addresses meaning this machine, and a server listening on::1does not answer on it. Node dev servers commonly bind IPv6 loopback only, so the route was dead the moment it was added.Measured on a real IPv6-only dev server:
The shorthand is now
localhost:<port>. Go's dialer tries both families for a name and takes whichever answers (RFC 6555), which is what the browser was doing all along when the user checkedlocalhost:3000, saw their app, and concluded Switchboard was broken.Why the old failure was expensive
The app plainly worked.
lssaiddown. That is the same wordlsuses for a server that is not running at all, so the only diagnostic available pointed away from the cause.Before and after, against the same live server:
Scope
Nothing on disk changes.
port = 3000stays exactly as written. Only the address derived from it moves, so every existing route gets this without anyone editing a config.lsanddoctorcome along for free, since both probe throughUpstreamAddr.--upstreamis untouched. Naming an address is how you say you meant that address.Only the outbound dial changes. Every socket Switchboard listens on stays pinned to
127.0.0.1. The security claim is unaffected.Testing
All packages pass,
GOOS=linuxandGOOS=windowsbuild clean. Two existing tests asserted the old address and were updated — the behaviour they pinned is the behaviour being fixed.Worth flagging:
go testhad these cached as passing after the change.go clean -testcachewas needed to see the failures.No test binds a real IPv6 socket. CI runners cannot be assumed to have IPv6, and a test that silently skips there would give the least coverage exactly where a regression is likeliest to slip through.
TestUpstreamAddrpins the returned string instead, which is what a regression would actually change.Not included
The diagnostic for someone who writes
--upstream 127.0.0.1:3000explicitly against an IPv6-only server. They still get a baredown. Rarer now that the default path works, and worth its own issue if you want it.Also no CHANGELOG entry, to avoid conflicting with #30, which is still open and rewrites that file. Happy to add one once it merges.