libp2p-tcp
Advanced tools
Comparing version 0.14.4 to 0.14.5
@@ -0,1 +1,11 @@ | ||
<a name="0.14.5"></a> | ||
## [0.14.5](https://github.com/libp2p/js-libp2p-tcp/compare/v0.14.4...v0.14.5) (2020-04-28) | ||
### Bug Fixes | ||
* catch error from maConn.close ([#128](https://github.com/libp2p/js-libp2p-tcp/issues/128)) ([0fe0815](https://github.com/libp2p/js-libp2p-tcp/commit/0fe0815)) | ||
<a name="0.14.4"></a> | ||
@@ -2,0 +12,0 @@ ## [0.14.4](https://github.com/libp2p/js-libp2p-tcp/compare/v0.14.3...v0.14.4) (2020-02-24) |
{ | ||
"name": "libp2p-tcp", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"description": "Node.js implementation of the TCP module that libp2p uses, which implements the interface-connection and interface-transport interfaces", | ||
@@ -5,0 +5,0 @@ "leadMaintainer": "Jacob Heun <jacobheun@gmail.com>", |
@@ -16,2 +16,15 @@ 'use strict' | ||
/** | ||
* Attempts to close the given maConn. If a failure occurs, it will be logged. | ||
* @private | ||
* @param {MultiaddrConnection} maConn | ||
*/ | ||
async function attemptClose (maConn) { | ||
try { | ||
maConn && await maConn.close() | ||
} catch (err) { | ||
log.error('an error occurred closing the connection', err) | ||
} | ||
} | ||
module.exports = ({ handler, upgrader }, options) => { | ||
@@ -32,3 +45,3 @@ const listener = new EventEmitter() | ||
log.error('inbound connection failed', err) | ||
return maConn && maConn.close() | ||
return attemptClose(maConn) | ||
} | ||
@@ -56,3 +69,3 @@ | ||
return new Promise((resolve, reject) => { | ||
server.__connections.forEach(maConn => maConn.close()) | ||
server.__connections.forEach(maConn => attemptClose(maConn)) | ||
server.close(err => err ? reject(err) : resolve()) | ||
@@ -59,0 +72,0 @@ }) |
Sorry, the diff of this file is not supported yet
1639624
45
2194