close connect() stream on rpc closed

This commit is contained in:
Andre Staltz 2024-01-14 13:09:44 +02:00
parent ae3d1d83d8
commit 6e54ca2724
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 4 additions and 1 deletions

View File

@ -57,7 +57,7 @@ function initSync(peer, config) {
}
/**
* @param {{ shse: SHSE, sync: { connect: GetDuplex } }} rpc
* @param {{ shse: SHSE, sync: { connect: GetDuplex }, once: CallableFunction }} rpc
* @param {boolean} iamClient
*/
function onSyncRPCConnect(rpc, iamClient) {
@ -80,6 +80,9 @@ function initSync(peer, config) {
}
})
abort = pull(local, remote, local)
rpc.once('closed', () => {
abort?.(true, () => {})
})
if (started) stream.initiate()
}
peer.on('rpc:connect', onSyncRPCConnect)