Repository navigation
Conversation
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 14, 2026 11:29
f42d674 to
509e691
Compare
EhabY
added this pull request to stack #137
October 14, 2026 11:32
EhabY
force-pushed
the
chore/repair-fork-ci
branch
from
October 14, 2026 11:49
2e8d147 to
e5a42bc
Compare
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 14, 2026 11:49
509e691 to
5cfc057
Compare
EhabY
force-pushed
the
chore/repair-fork-ci
branch
from
October 14, 2026 11:58
e5a42bc to
4701f15
Compare
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 14, 2026 11:59
5cfc057 to
1fe5e63
Compare
EhabY
force-pushed
the
chore/repair-fork-ci
branch
from
October 14, 2026 12:19
4701f15 to
ccf2c31
Compare
EhabY
force-pushed
the
fix/upnp-shutdown
branch
2 times, most recently
from
October 14, 2026 13:39
9c3bb27 to
c82775e
Compare
EhabY
removed this pull request from stack #137
October 14, 2026 13:47
EhabY
force-pushed
the
fix/upnp-shutdown
branch
2 times, most recently
from
October 14, 2026 19:09
ac58a7f to
0825918
Compare
EhabY
marked this pull request as ready for review
October 14, 2026 19:12
Member
There was a problem hiding this comment.
Curious what led to this change being warranted? My agent couldnt find a linear issue but it looks like it's fixing real issues? some of these issues also appear unfixed on upstream tailscale
For the stuff that is fixed upstream my preference would probably be that we cherry pick fixes from upstream directly
Author
|
I encountered this issue while running tests locally, they were flakey because connections stayed open beyond the test and triggered the "flake detection" occasionally. Is this a real issue that somehow impacts user? Not so sure. But it seems part of this fix is already upstream and the rest have open issues 🙏 |
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 15, 2026 11:39
0825918 to
737bde5
Compare
Query and validate the external IP before AddPortMapping, so a failed lookup cannot leave an untracked mapping on the router. This ports the reordering from upstream commit 91d10d3 ("net/portmapper: avoid leaking permanent UPnP mappings"). The fork has neither selectBestService nor the permanent-lease retry, so the rest of that commit and its tests do not apply; the next commit covers this behavior in TestUPnPMappingLifecycle. (cherry picked from commit 91d10d3)
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 15, 2026 11:49
737bde5 to
64b9cea
Compare
Stop starting mapping attempts after Close, and release mappings that complete after Close instead of storing them. Close idle UPnP HTTP connections on Close, and again when a mapping attempt that was in flight during Close finishes, so no pooled connections outlive the client.
Release runs while holding Client.mu, so an unresponsive router could block Close, SetLocalPort, and gateway changes indefinitely. Limit DeletePortMapping to one second, matching the UPnP discovery fetch.
EhabY
force-pushed
the
fix/upnp-shutdown
branch
from
October 15, 2026 12:45
64b9cea to
af40220
Compare
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.
Fix flaky tests caused by UPnP state outliving
portmapper.Client.Close(), and stop leaking router mappings.91d10d38ae: query and validate the external IP beforeAddPortMapping, so a failed lookup cannot leave an untracked mapping on the router. Only the reordering applies; the fork lacksselectBestServiceand the permanent-lease retry that the rest of that commit touches.Close(): stop starting mapping attempts afterClose(), release mappings that complete after it instead of storing them, and close idle UPnP HTTP connections onClose()(and again when a mapping attempt in flight duringClose()finishes) so pooled connections and their goroutines do not outlive the client. Connection reuse within an attempt and the 2s idle timeout are unchanged. Not fixed upstream.DeletePortMappingto one second.Releaseruns while holdingClient.mu, so an unresponsive router could blockClose,SetLocalPort, and gateway changes indefinitely. Tracked upstream in tailscaled blocks ~35s on shutdown in portmapper UPnP release (context.Background, no timeout) tailscale/tailscale#21625; open fixes there (net/portmapper: add UPnP-IGD release timeout tailscale/tailscale#17615, net/portmapper: put mappings and releases into an execqueue tailscale/tailscale#18460, fix: bound UPnP mapping release with a 5s timeout tailscale/tailscale#21687) are not merged.Validation
go vetandgo test -race ./net/portmapper/on its own; builds pass for./..., windows, darwin, linux/arm, js/wasm.TestUPnPMappingLifecycle(commit 2) also covers commit 1's failed-IP-lookup cases, since upstream's tests rely on test infrastructure the fork does not have. It uses a transport without an idle timeout, so connections only close ifClose()closes them.CloseIdleConnectionscall, removing the late-mapping release, restoring the old IP-lookup order, and removing the release timeout each make the new tests fail.Generated with Coder Agents on behalf of @EhabY.