Repository navigation
fix(nat): harden udp lifecycle and prepare 0.1.2 - #3
Merged
Merged
Conversation
Keep native UDP error handling active after bind, reject pending work on error or close, and share close completion. Tolerate already-closed handles and retry native close when an implicit bind failure discards Node's queued close operation. Detach PMP/PCP sockets before asynchronous teardown, cancel unfinished binds, and recover from failed binds. Scope callbacks to their socket and request so old sends, messages, and reused nonces cannot affect a newer request. Stop STUN/UPnP work after timeout or abort and release listeners. Add deterministic race coverage and real Node UDP lifecycle tests. All 433 default-suite tests pass; four opt-in Docker matrix tests are skipped. Lint, typecheck, and build pass. Motrix's 12 NAT integration tests also pass when loading this built library via a temporary test alias. Related to agalwood/Motrix#2165. That issue's reported Windows stack was fixed separately in TrackerProber; this change hardens the NAT library.
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.
Prepare
@motrix/nat0.1.2 with UDP lifecycle hardening. Network errors after bind stay within the NAT layer, pending operations settle on close, and concurrent callers share close completion. Native close also recovers when an implicit bind failure discards Node's queued cleanup.PMP/PCP now cancels unfinished binds, retries failed binds with fresh sockets, and prevents old callbacks or reused nonces from affecting newer requests. STUN/UPnP stops sending after timeout or cancellation and releases listeners.
The reported stack in agalwood/Motrix#2165 was independently traced to TrackerProber and fixed in the app. This release adds defense to the NAT package; it does not claim that NAT caused that stack.
Validation:
pnpm run prepublishOnly: lint, typecheck, 433 passing tests, and build; four opt-in Docker cases skipped locally.npm pack --dry-run: only distribution files, package metadata, license, and bilingual READMEs; zero runtime dependencies.