diff --git a/lib/index.js b/lib/index.js index 2806ad2..749d21f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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)