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

fix: don't error to specific #235

Merged
merged 1 commit into from
Mar 13, 2018
Merged

fix: don't error to specific #235

merged 1 commit into from
Mar 13, 2018

Conversation

vmx
Copy link
Contributor

@vmx vmx commented Mar 9, 2018

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.

@ghost ghost assigned vmx Mar 9, 2018
@ghost ghost added the in progress label Mar 9, 2018
@vmx
Copy link
Contributor Author

vmx commented Mar 9, 2018

I'm not sure if that's the proper fix. I hope @richardschneider would know.

@vmx
Copy link
Contributor Author

vmx commented Mar 9, 2018

It's not the proper fix. It also failed for me. I need to revisit this on Monday.

@vmx
Copy link
Contributor Author

vmx commented Mar 9, 2018

Sorry for the noise, with increasing the timeout it seems to now pass all the time. So please review.

// TODO: go-ipfs returns an error, https://github.com/ipfs/go-ipfs/issues/4078
ipfs.stop((err) => {
if (err && err.message !== 'read ECONNRESET') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the removal. Normally ipfs.stop should not return an error. There is a bug in go, in that it closes the connection before sending the result.

Copy link
Contributor Author

@vmx vmx Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that the error message on Browsers is different from read ECONNRESET. So this check would fail, and the whole test case would fail. Hence I allow one error (no matter which message) to happen (due to the bug in Go).

Edit: Another way doing this would be:

        if (err && err.message !== 'read ECONNRESET' && isNode) {
          expect(err).to.not.exist()
        }

This way it would be skipped if the test if run from the Browser.

if (err && err.message !== 'read ECONNRESET') {
expect(err).to.not.exist()
}
// Retry
ipfs.stop((err) => {
expect(err).to.exist()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error should not exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, then we need to check for go and then expect an error

if (!withGo)
   expect(err).to.not.exist()

Here's an example of detecting go-ipfs.

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.
@vmx
Copy link
Contributor Author

vmx commented Mar 12, 2018

I finally understood what the test is actually doing. I added a commit which hopefully also makes it clearer for others.

@daviddias
Copy link
Contributor

@vmx do you confirm that this indeed passes with js-ipfs and js-ipfs-api? If so, I'll merge and release

@vmx
Copy link
Contributor Author

vmx commented Mar 12, 2018

@diasdavid I confirm that the miscellaneous.spec.js passes with js-ipfs-api on Windows and Linux. js-ipfs doesn't run these tests at all atm.

@daviddias
Copy link
Contributor

@vmx does run them as well, it just never got the file renamed, still named generic.js https://github.com/ipfs/js-ipfs/blob/master/test/core/interface/generic.js

@vmx
Copy link
Contributor Author

vmx commented Mar 12, 2018

@diasdavid js-ipfs generic.js passes on Windows and Linux.

@daviddias daviddias merged commit ec16016 into master Mar 13, 2018
@ghost ghost removed the in progress label Mar 13, 2018
@daviddias daviddias deleted the stop-less branch March 13, 2018 20:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants