Detect silent relay failures: after each batch, mark relays with no response as timed out (catches DNS errors, connection refused, HTTP handshake failures that NDK doesn't emit relay:publish:failed for)

This commit is contained in:
Laan Tungir
2026-06-30 11:24:45 -04:00
parent b03b848909
commit d04844cce8
2 changed files with 16 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
{
"VERSION": "v0.7.82",
"VERSION_NUMBER": "0.7.82",
"BUILD_DATE": "2026-06-30T15:07:27.716Z"
"VERSION": "v0.7.83",
"VERSION_NUMBER": "0.7.83",
"BUILD_DATE": "2026-06-30T15:24:45.710Z"
}

View File

@@ -6373,6 +6373,19 @@ async function handlePublish(requestId, event, port) {
} catch (batchErr) {
// Expected — some relays in this batch may fail.
}
// --- Detect silent failures ---
// NDK's relay.publish() can resolve false without emitting
// relay:publish:failed (e.g., DNS errors, connection refused,
// HTTP handshake failures). These relays are not in any of
// our tracked sets. Mark them as timed out so they get
// skip-marked and don't waste time on the next publish.
for (const url of batch) {
if (!publishedSoFar.has(url) && !failedSoFar.has(url) && !timedOutSoFar.has(url)) {
timedOutSoFar.add(url);
const elapsed = ((Date.now() - publishStartTime) / 1000).toFixed(1);
console.log(`[Worker][broadcast] ⏱️ ${url} SILENT TIMEOUT (${elapsed}s) — batch ${currentBatch}/${totalBatches} (no response, likely connection failure)`);
}
}
// Emit a progress event with batch info after each batch.
broadcast({
type: 'broadcastProgress',