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

Commit

Permalink
fix: ensure timeline.close is set (#113)
Browse files Browse the repository at this point in the history
* fix(test): dns4 isnt a valid tcp multiaddr

It should be resolved first

* fix: ensure timeline.close is set on the multiaddrConn

* chore: add docs to gitignore

They are generated and uploaded on release
  • Loading branch information
jacobheun committed Sep 19, 2019
1 parent 872e15a commit 605ee27
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
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

0 comments on commit 605ee27

Please sign in to comment.