Skip to content

Commit 6e0bba5

Browse files
authored
NYM-1502: Fix a crash when network reconnected on Windows. (#5508)
When the connection is re-established the callback thread was not running in a `tokio`-managed thread which caused a panic.
1 parent b0cbce7 commit 6e0bba5

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

nym-vpn-core/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
### Fixed
2323

2424
- [Android] Diagnostic doesn't panic because of uninitialized context (https://github.com/nymtech/nym-vpn-client/pull/5415)
25-
25+
- [Windows] Fix a crash when the network reconnected (https://github.com/nymtech/nym-vpn-client/pull/5508)
2626

2727
## [1.30] - 2026-05-29
2828

nym-vpn-core/crates/nym-offline-monitor/src/windows.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl BroadcastListener {
5353
},
5454
notify_tx,
5555
pending_online_cancel: None,
56+
rt_handle: tokio::runtime::Handle::current(),
5657
}));
5758

5859
let state = system_state.clone();
@@ -183,8 +184,12 @@ enum StateChange {
183184
struct SystemState {
184185
connectivity: ConnectivityInner,
185186
notify_tx: watch::Sender<Connectivity>,
187+
186188
/// Cancels a pending "Connected" notification during the stabilisation delay.
187189
pending_online_cancel: Option<CancellationToken>,
190+
191+
/// Tokio runtime handle to run callbacks in
192+
rt_handle: tokio::runtime::Handle,
188193
}
189194

190195
impl SystemState {
@@ -222,7 +227,7 @@ impl SystemState {
222227
self.pending_online_cancel = Some(cancel.clone());
223228
let notify_tx = self.notify_tx.clone();
224229
let online_connectivity = self.connectivity.into_connectivity();
225-
tokio::spawn(async move {
230+
self.rt_handle.spawn(async move {
226231
tokio::select! {
227232
_ = tokio::time::sleep(ONLINE_STABILIZATION_DELAY) => {
228233
tracing::info!("Connectivity changed: Connected");

0 commit comments

Comments
 (0)