Repository navigation
Harden MWC Slatepack runtime and listener lifecycle - #17
Merged
Merged
Conversation
This was referenced Nov 20, 2026
sneurlax
force-pushed
the
fix/slatepack-runtime-safety
branch
4 times, most recently
from
December 1, 2026 17:15
899d0a0 to
84815e2
Compare
sneurlax
force-pushed
the
fix/slatepack-runtime-safety
branch
from
December 1, 2026 18:06
84815e2 to
041c8f2
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.
Summary
Hardens the MWC runtime paths used by Stack Wallet's shared Slatepack UI.
txFinalizereturnsposted)Listener lifecycle
startMwcMqsListenerreturnsMwcMqsListenerStartResult(started,reused,keptOtherWallet,deferredToPreferredWallet). It reportsstartedonce the worker has run for 2 s, which catches relays that fail by name, connection or TLS. When the worker ends during startup it throws with the native error, or with the relay it could not keep. Why a listener that ended on its own ended is kept inListenerManager.lastExitError.allowTakeover: true(the wallet on screen) replaces another wallet's listener and makes the wallet preferred once its listener runs, or once it has told the previous listener to stop. A takeover that fails to start its own listener does not change the preference. While the preferred wallet has no running listener, other wallets defer to it only for 5 minutes after its last start, health check or stop, so a recovering wallet keeps its priority and a handle that is no longer used (for example after the wallet was reopened) stops blocking the others.releasePreference: truegives the priority up on exit. Listener timing uses a monotonic clock.The listener's running state still reports worker health, not a completed relay authentication: a relay that never answers is noticed only once the worker ends, up to 30 s later, and Stack Wallet's periodic
startMwcMqsListenercall then replaces it. Upstream registers the broker inside the same call that starts it, so a start cancelled at that moment can run its broker briefly before the watcher stops it.Verification
cargo test --locked: 3 passed, including a native start failure that reports its error, the one-listener slot, and a released idflutter test test/protocol_result_test.dart: 23 passed. The listener state machine is driven through a fake native layer (reuse, background start, takeover, failed takeover, takeover while the previous listener is still stopping, preference expiry, unfinished stop, a leftover listener from another isolate, the exit reason, start errors, settle, late start and timeout, stop not holding the wallet mutex), plus one start failure through the real native librarydart analyze lib test: no errors; 1 existing warningdnix.lockrebuilt for all 11 targets on macOS with Nix and Xcode 27.0 (native-0a96723388a1)