Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 0299b40

Browse files
committed
fix: don't error to specific
When stopping an IPFS node it returns an error. The error message depends on the environment. In Browsers it might also return `Failed to fetch` or `XHR error`. Hence removing the specific error check as it would fail for Browsers. Instead check if the node is an go-ipfs one.
1 parent c4934ca commit 0299b40

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

js/src/miscellaneous.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ chai.use(dirtyChai)
1111
module.exports = (common) => {
1212
describe('.miscellaneous', () => {
1313
let ipfs
14+
let withGo
1415

1516
before(function (done) {
1617
// CI takes longer to instantiate the daemon, so we need to increase the
@@ -22,7 +23,11 @@ module.exports = (common) => {
2223
factory.spawnNode((err, node) => {
2324
expect(err).to.not.exist()
2425
ipfs = node
25-
done()
26+
ipfs.id((err, id) => {
27+
expect(err).to.not.exist()
28+
withGo = id.agentVersion.startsWith('go-ipfs')
29+
done()
30+
})
2631
})
2732
})
2833
})
@@ -83,12 +88,15 @@ module.exports = (common) => {
8388
})
8489

8590
// must be last test to run
86-
it('.stop', (done) => {
87-
// TODO: go-ipfs returns an error, https://github.com/ipfs/go-ipfs/issues/4078
91+
it('.stop', function (done) {
92+
this.timeout(10 * 1000)
8893
ipfs.stop((err) => {
89-
if (err && err.message !== 'read ECONNRESET') {
94+
// TODO: go-ipfs returns an error, https://github.com/ipfs/go-ipfs/issues/4078
95+
if (!withGo) {
9096
expect(err).to.not.exist()
9197
}
98+
// Trying to stop an already stopped node should return an error
99+
// as the node can't respond to requests anymore
92100
ipfs.stop((err) => {
93101
expect(err).to.exist()
94102
done()

0 commit comments

Comments
 (0)