fix(tunnel:single): Windows port type error and stuck state#89
Merged
Conversation
The --port option arrives as a string from Symfony Console, but TunnelManager::create() is typed ?int, causing a fatal TypeError when the flag is used. Validate the string and cast to int before passing it on. The persistent tunnel state tracked in tunnel-info.json only cleans up dead PIDs via posix_kill, which does not exist on Windows. The first tunnel opened was therefore recorded as "still open" forever and subsequent runs exited with "A tunnel is already opened". Since tunnel:single runs in the foreground on Windows (no background tunnels are supported there), skip both the isOpen() check and saveNewTunnel() on Windows so no persistent state is written. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes two Windows-specific bugs in upsun tunnel:single: a TypeError caused by passing the string --port value to a strictly-typed ?int parameter, and a stuck "tunnel already opened" state caused by posix_kill() being unavailable on Windows (so stale entries in tunnel-info.json were never cleaned up).
Changes:
- Read the
--portoption into a separate variable, validate it asint|string, and cast tointbefore passing toTunnelManager::create(). - Skip
isOpen()andsaveNewTunnel()on Windows via a new$trackStateflag, since persistent state can't be cleaned up there andtunnel:singleruns in the foreground anyway.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
miguelsanchez-upsun
approved these changes
May 26, 2026
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.
Summary
Two bugs reported against
upsun tunnel:singleon Windows in CLI 5.10.4:1.
--portcauses a fatal TypeError.InputOption::VALUE_REQUIREDreturns the value as a string, butTunnelManager::create()is typed?int, soupsun tunnel:single --port 30005crashed with:Now the option is validated as a string (the validators accept
int|string) and cast tointbefore being passed on.2. Tunnel state gets stuck after the first run.
The persistent state in
tunnel-info.jsonis cleaned up viaposix_kill($pid, 0), which doesn't exist on Windows. So once a tunnel was recorded, the entry was never removed, and the nexttunnel:singleexited with "A tunnel is already opened" forever.Since
tunnel:singleruns in the foreground on Windows (the backgroundtunnel:openis explicitly disabled there), the persistent state isn't really useful —tunnel:list/info/closeonly make sense when the tunnel command has already returned. The fix skips both theisOpen()check andsaveNewTunnel()on Windows, so no state is written and there's nothing to get stuck.Existing stale entries in users'
tunnel-info.jsonbecome harmless after this change — they're never read bytunnel:singleon Windows.