fix(nip46): gate remaining trace writes to live relay sessions
The wrong-identity refusal test and the auto-name retry loop still wrote into the live pairing-trace.log on every e2e run: three bogus "restored signer answered as a different account" npubs and phantom "auto-name attempt" lines were test traffic, not live Amber misbehaviour, and they kept derailing the forensics review. fail and the background enrichment traces now check live_relays like every other trace site. Verified: running the e2e suite appends zero lines to the trace file.
This commit is contained in:
parent
704addc773
commit
332ab647c9
1 changed files with 44 additions and 14 deletions
|
|
@ -1305,7 +1305,22 @@ impl Nip46ClientSigner {
|
|||
let message = message.into();
|
||||
eprintln!("[nip46] session failed: {message}");
|
||||
eprintln!("[NIP46] session failed: {message}");
|
||||
pairing_trace(&format!("session failed: {message}"));
|
||||
// Forensics-log only LIVE sessions. The e2e harness deliberately
|
||||
// fails restored sessions (wrong-identity refusal test), and its
|
||||
// "session failed" lines were landing in pairing-trace.log among
|
||||
// real ones — three different bogus "restored signer answered as a
|
||||
// different account" npubs turned out to be test runs, not live
|
||||
// Amber misbehaviour. Read the relays under a short lock before the
|
||||
// mutating one below.
|
||||
let relays = self
|
||||
.inner
|
||||
.try_lock()
|
||||
.ok()
|
||||
.and_then(|g| g.connection.as_ref().map(|c| c.relays.clone()))
|
||||
.unwrap_or_default();
|
||||
if live_relays(&relays) {
|
||||
pairing_trace(&format!("session failed: {message}"));
|
||||
}
|
||||
if let Ok(mut inner) = self.inner.try_lock() {
|
||||
// First failure wins: the demux loop exits with a generic
|
||||
// "Connect handshake failed" AFTER the handshake task already
|
||||
|
|
@ -2328,6 +2343,7 @@ impl Nip46ClientSigner {
|
|||
// UI polls status and vault, so the row fills in a moment later.
|
||||
{
|
||||
let app = self.app.clone();
|
||||
let live_enrichment = live_relays(&connection.relays);
|
||||
tokio::spawn(async move {
|
||||
let relays_for_meta = {
|
||||
let app = app.lock().await;
|
||||
|
|
@ -2358,15 +2374,27 @@ impl Nip46ClientSigner {
|
|||
meta = Some(found);
|
||||
break;
|
||||
}
|
||||
Ok(Ok(None)) => pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: no kind-0 found on any relay"
|
||||
)),
|
||||
Ok(Err(join_err)) => pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: fetch task panicked: {join_err}"
|
||||
)),
|
||||
Err(_) => pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: fetch timed out (75s budget)"
|
||||
)),
|
||||
Ok(Ok(None)) => {
|
||||
if live_enrichment {
|
||||
pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: no kind-0 found on any relay"
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(Err(join_err)) => {
|
||||
if live_enrichment {
|
||||
pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: fetch task panicked: {join_err}"
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
if live_enrichment {
|
||||
pairing_trace(&format!(
|
||||
"auto-name attempt {attempt}: fetch timed out (75s budget)"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if attempt < 4 {
|
||||
tokio::time::sleep(Duration::from_secs(20)).await;
|
||||
|
|
@ -2376,10 +2404,12 @@ impl Nip46ClientSigner {
|
|||
Some(meta) => meta,
|
||||
None => return,
|
||||
};
|
||||
pairing_trace(&format!(
|
||||
"auto-name: kind-0 fetched (display_name={:?} name={:?})",
|
||||
meta.display_name, meta.name
|
||||
));
|
||||
if live_enrichment {
|
||||
pairing_trace(&format!(
|
||||
"auto-name: kind-0 fetched (display_name={:?} name={:?})",
|
||||
meta.display_name, meta.name
|
||||
));
|
||||
}
|
||||
let mut app = app.lock().await;
|
||||
let mut changed = false;
|
||||
if let Some(row) = app
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue