fix: send file-done before closing file DC to avoid control channel race

Closing the file DataChannel can trigger SCTP/ICE cleanup before the
file-done control message is flushed, causing a 15 s timeout on the
receiver. Send file-done first on both the Go and TS sender paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-07-02 18:50:12 +02:00
parent 3a105e2c9a
commit 153426367d
2 changed files with 6 additions and 4 deletions

View File

@@ -510,9 +510,10 @@ export class PeerConn {
this.events.fileSendProgress?.({ peer: this.peerId, xid, name: file.name, sent: resumeOffset + localOffset, total: file.size })
await new Promise(r => setTimeout(r, 0))
}
dc.close()
// §9: send file-done with sha256 so receiver can verify integrity.
// §9: send file-done before closing the file DC so the control channel
// is still healthy when the message is dispatched.
this._dc({ type: 'file-done', xid, sha256: hash })
dc.close()
this.events.fileSent?.({ peer: this.peerId, xid, name: file.name })
}