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

fix: ensure timeline.close is set #113

Merged
merged 3 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
package-lock.json
coverage
.nyc_output
docs
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"aegir": "^20.0.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"interface-transport": "^0.6.1",
"interface-transport": "^0.7.0",
"sinon": "^7.3.1"
},
"dependencies": {
Expand All @@ -45,7 +45,7 @@
"debug": "^4.1.1",
"err-code": "^2.0.0",
"ip-address": "^6.1.0",
"mafmt": "^6.0.9",
"mafmt": "^7.0.0",
"multiaddr": "^7.1.0",
"stream-to-it": "^0.1.1"
},
Expand Down
9 changes: 9 additions & 0 deletions src/socket-to-conn.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,14 @@ module.exports = (socket, options) => {
}
}

socket.once('close', () => {
// In instances where `close` was not explicitly called,
// such as an iterable stream ending, ensure we have set the close
// timeline
if (!maConn.timeline.close) {
maConn.timeline.close = Date.now()
}
})

return maConn
}
3 changes: 1 addition & 2 deletions test/compliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe('interface-transport compliance', () => {
const addrs = [
multiaddr('/ip4/127.0.0.1/tcp/9091'),
multiaddr('/ip4/127.0.0.1/tcp/9092'),
multiaddr('/ip4/127.0.0.1/tcp/9093'),
multiaddr('/dns4/ipfs.io')
multiaddr('/ip4/127.0.0.1/tcp/9093')
]

// Used by the dial tests to simulate a delayed connect
Expand Down