portmapper: synchronous HomeRouter lookup blocks the Tokio worker
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- networking
Research direction
Start in the portmapper async service, where HomeRouter::new() is called synchronously before probing or creating a mapping, and check the existing private helpers that the proposal would await. Run the reduced probe_keeps_timers_running control on a current_thread runtime to reproduce the blocked timer. Done means HomeRouter::new runs under spawn_blocking, task failure maps to ProbeError::Join, the public API is unchanged, and the timer completes near 100 ms.
Written by the indexing model from the issue text.
Description
In portmapper 0.20.0, the async service calls synchronous HomeRouter::new() before probing or creating a mapping. A slow interface/gateway lookup can stall unrelated tasks on that Tokio worker.
On Windows, a public-API control with all three mapping protocols disabled delayed a 100 ms timer to 1,154 ms. With the lookup on spawn_blocking, the same timer completed in 101 ms while lookup was still pending. These are local observations, not a portable timing guarantee. Current main still has the same gateway code.
Would moving HomeRouter::new to spawn_blocking, awaiting it through the existing private helpers, and mapping task failure to ProbeError::Join be acceptable? This would keep the public API and protocol selection unchanged. It is separate from the UPnP socket teardown in #236/#254 and the already-offloaded WMI default-route call in #124.
The one-file release-based candidate passes cargo +1.91.0 check --locked -p portmapper.
Reduced public-API control
#[tokio::test(flavor = "current_thread")]
async fn probe_keeps_timers_running() {
let client = portmapper::Client::new(portmapper::Config {
enable_upnp: false,
enable_pcp: false,
enable_nat_pmp: false,
protocol: portmapper::Protocol::Udp,
});
let _probe = client.probe();
let started = std::time::Instant::now();
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
eprintln!("100 ms timer: {:?}", started.elapsed());
}
The observed delay depends on the machine's gateway lookup; this control does not establish its duration on other systems.
- Dominant language
- Rust
- Stars
- 34
- Forks
- 56
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from n0-computer/net-tools
-
Difficulty 1/5 1-3 hours Newbie friendliness 33/100
n0-computer/net-tools#280 ·
Maintainers usually reply within 2 days
-
netwatch: objc2-system-configuration with default features pulls objc2-security into every macOS buildPossibly taken @flub claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
n0-computer/net-tools#278 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
n0-computer/net-tools#276 ·
Maintainers usually reply within 2 days
-
netwatch never turns on noq-udp's Apple fast path, so iroh's `fast-apple-datapath` does nothingOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
n0-computer/net-tools#272 ·
Maintainers usually reply within 2 days
-
Windows: endpoints hang or crash when several bind at once (concurrent WMI default-route queries?)Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
n0-computer/net-tools#271 ·
Maintainers usually reply within 2 days
All issues in n0-computer/net-tools
Similar issues
-
area:web kind:bug priority:p2 ready
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
sims1253/r-typeshed#140 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
storytold/craft-libs#2867 ·
Maintainers usually reply within 1 day
-
help wanted needs investigation priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 62/100