diff --git a/src/signer.rs b/src/signer.rs index 84e8d7a..303bccd 100644 --- a/src/signer.rs +++ b/src/signer.rs @@ -626,7 +626,11 @@ async fn run_sign_task(signer: Signer, app: Arc>, uri: C } }; - // 3. Connect to the client's relays. + // 3. Connect to the client's relays. The notification stream is opened + // BEFORE anything is sent or subscribed: the client acknowledges our + // announcement within milliseconds, and a receiver created afterwards + // would miss those early messages (tokio broadcast semantics), leaving + // the client waiting forever for a reply. let client = Client::new(keys.clone()); for url in &uri.relays { if let Err(err) = client.add_relay(url.to_string()).await { @@ -634,6 +638,7 @@ async fn run_sign_task(signer: Signer, app: Arc>, uri: C return; } } + let mut notifications = client.notifications(); client.connect().await; client.wait_for_connection(CONNECT_TIMEOUT).await; @@ -651,7 +656,6 @@ async fn run_sign_task(signer: Signer, app: Arc>, uri: C } // 6. Answer requests until the connection goes away or we are stopped. - let mut notifications = client.notifications(); loop { let notification = match notifications.recv().await { Ok(notification) => notification,