fix: force close of streams instead of reset when closing connection (#1466)

This commit is contained in:
richΛrd
2025-06-20 08:57:20 -04:00
committed by GitHub
parent 9c153c822b
commit f028ad8c12
2 changed files with 8 additions and 2 deletions

View File

@@ -512,7 +512,14 @@ method close*(m: Yamux) {.async: (raises: []).} =
trace "Closing yamux"
let channels = toSeq(m.channels.values())
for channel in channels:
await channel.reset(isLocal = true)
for (d, s, fut) in channel.sendQueue:
fut.fail(newLPStreamEOFError())
channel.sendQueue = @[]
channel.sendWindow = 0
channel.closedLocally = true
channel.opened = false
await channel.remoteClosed()
channel.receivedData.fire()
try:
await m.connection.write(YamuxHeader.goAway(NormalTermination))
except CancelledError as exc:

View File

@@ -63,7 +63,6 @@ suite "Perf protocol":
checkTrackers()
asyncTest "tcp::yamux":
return # nim-libp2p#1462 test fails with stream closed error
let server = createSwitch(isServer = true, useYamux = true)
let client = createSwitch(useYamux = true)
await runTest(server, client)