Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: connection close should return promise
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Mar 29, 2021
1 parent 2d5eaf1 commit c92a92c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/stream-to-ma-conn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const log = debug('libp2p:stream:converter')

/**
* @typedef {import('multiaddr')} Multiaddr
* @typedef {import('libp2p-interfaces/src/transport/types').MultiaddrConnection} MultiaddrConnection
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
*
* @typedef {Object} Timeline
Expand Down Expand Up @@ -57,17 +58,17 @@ function streamToMaConnection ({ stream, remoteAddr, localAddr }, options = {})
remoteAddr,
/** @type {Timeline} */
timeline: { open: Date.now(), close: undefined },

close () {
sink(new Uint8Array(0))
close()
return close()
}
}

function close () {
if (!maConn.timeline.close) {
maConn.timeline.close = Date.now()
}
return Promise.resolve()
}

return maConn
Expand Down

0 comments on commit c92a92c

Please sign in to comment.