-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/handle network failure in google node #199
Feature/handle network failure in google node #199
Conversation
b38163b
to
f538db2
Compare
Changes Unknown when pulling f538db2 on elvetemedve:feature/handle-network-failure-in-google-node into ** on node-red:master**. |
this PR seems good but seems to also address a lot of other tests... |
Splitting the PR would cause one PR dependent on the other. I would rather update the description. |
Sure. Happy to have the contribution either way. |
I described the changes I made to tests in the Proposed changes section. I hope it makes sense. :) Something must be wrong with Travis CI build configuration, because |
Installed packages: - backoff Updated packages: - sinon - should - nock - mocha
Currently there is a bug when a network error occurs during obtaining access token. The error is not reported to the caller via the callback function, so the caller waits forever for the response. Secondly this commit adds network error tolerance by retrying the failed HTTP request 4 times (resulting a total of 5 HTTP request). Furthermore it waits between retries using exponential backoff strategy according to this formula: delay = 100 * 9^n where - delay is the time passes between HTTP calls in milliseconds - n is the retry counter (starting from 0)
Current code only handles token refresh error, but the main HTTP request could fail also and should be retried as well. This commit adds a handler which retries failed HTTP request 4 times (resulting a total of 5 HTTP requests).
f538db2
to
486320f
Compare
Changes Unknown when pulling 486320f on elvetemedve:feature/handle-network-failure-in-google-node into ** on node-red:master**. |
Sounds good... but when I try it I get
multiple times... which file is that declared in ? I can't locate it. (Also updated the gruntfile to ignore node_modules... thanks for that...) |
|
sweet ! - Happy place - Many many thanks. |
Does this also close #189 ? |
Yes, exactly. |
This PR has broken multiple nodes.
|
Just to reiterate, the PR should have been split up to address individual issues. |
Regarding point 1) and 2), why Mocha did not catch these mistakes? I would have expected to see failing tests due to missing dependencies (at least on TravisCI, if not on my machine). |
The main package.json allows the whole repository to be tested. But you are right - this has highlighted a need for the tests to do more to verify the packaging of the individual nodes. It currently relies on us spotting such changes when reviewing PRs. |
Types of changes
Proposed changes
Probably solves issue #189. Errors during token refresh does not always reported back to the caller method. That's why node status is not updated to reflect failed status, but it remains in "querying" state.
To make network communication more fault tolerant, failed HTTP requests needs to be retried multiple times before giving up. Also a delay is added between these retries. In addition to that delay time is increased exponentially after each failed attempt to give a higher chance for the network to recover.
Finally following the "Leave the code in a better state than you found it." principle, I decided to make all spec tests passing (not just google nodes). Running Mocha on the current
master
branch reports a lot of failing tests. In order to be able to refactor the code or update 3rd-party dependencies more confidently, all tests should be kept in green state, otherwise it's not possible to detect defects brought in my the new changes (in this case updated npm packages does not break functionality).About half of the test changes are necessary because of Sinon.JS update, see migration guide to v3.x. Rest of the tests are broken because of various reasons.
Changelog
backoff
package to be able to retry failed HTTP requests with increasing delay between them.Checklist
grunt
to verify the unit tests pass