Files
swiftcontrol/packages
Jonas Bark f440cedb2b fix(local-network): stop the probe being deallocated before it answers
On macOS the probe could hang forever instead of returning. Traced in a debug
app run, the native side got as far as:

  handle check
  probe created
  listener ready          <- permission genuinely granted, no PolicyDenied
  browser ready
                          <- then nothing, for 10+ minutes

No browse results, and — the tell — the 3s timeout DispatchWorkItem never ran
either. It captures `[weak self]`, and `finish` logs on entry, so silence means
`self` was already nil: the Probe was deallocated mid-flight, taking the
NWListener and NWBrowser down with it. Dart then waited on a reply that could
never come.

Nothing held it. register(with:) handed the only reference to the plugin
straight to addMethodCallDelegate, so ARC was free to release the plugin, and
the probe hangs off the plugin. Retain the plugin for the process lifetime, and
have a running Probe retain itself from start until finish. The self-retain is
what makes a reply unconditional: every path that can answer Dart runs on a
callback, and an object that has been freed cannot run any of them.

Ruled out first, with evidence rather than reasoning: the permission prompt
racing the timeout (Jonas confirmed the toggle is on, and the listener/browser
reaching .ready says the same), and interference from BikeControl's own mDNS
responder on 5353 — with it genuinely bound and registered, the probe still
returns granted in 7-12ms.

Not yet confirmed against the original symptom: reproducing it needs Jonas's
debug setup. Launching the binary directly gives no NSApplication run loop (a
bare Dart Timer does not fire), and launching via `open` leaves no stdout to
read, so I could not get a trustworthy before/after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 13:36:29 +02:00
..
2026-05-13 08:23:19 +02:00