-
Notifications
You must be signed in to change notification settings - Fork 5k
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
XMLHttpRequest errors are not handled correctly #3425
Comments
@liamaharon Thanks for such a great description and analysis of this problem. |
As an FYI: With the error lacking any particular code to check on, we and probably others are checking for a string match and when the error message changes to something more informative, that change will probably break our ability to handle it robustly (mainly by waiting a bit and trying again). We will need to coordinate code changes around the time of upgrade to adjust for that breaking change. Therefore, I would definitely recommend against rolling out a fix for this on e.g. the patch version number. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment, otherwise this issue will be closed in 7 days |
I don't think this should be marked as stale. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
I still don't think this should be marked as stale. |
### Description - This change should fix the flakey `error: Invalid JSON RPC response: ""` error that we often see in the protocol test beforeEach hooks (particularly those for the Attestations contract). - Implements a custom beforeEachWithRetries hook for the protocol tests package that will optionally retry beforeEach hooks and add sleep in between retries. This is necessary to avoid flakiness that seems to be caused by port exhaustion in CI and a mishandling of the error by web3. (See web3/web3.js#3425 and web3/web3.js#926). - I've only added `beforeEachWithRetries` to the Attestations tests because this error appears there the most. We can add it elsewhere in the future as needed. ### Other changes None ### Tested To see that this works, search logs for "retry" in https://circleci.com/gh/celo-org/celo-monorepo/248635 ### Related issues - Fixes #4570 ### Backwards compatibility Not applicable
I wish I could do something to help with this, I keep seeing this error and have to write dirty workaround code to handle it every time. |
### Description - This change should fix the flakey `error: Invalid JSON RPC response: ""` error that we often see in the protocol test beforeEach hooks (particularly those for the Attestations contract). - Implements a custom beforeEachWithRetries hook for the protocol tests package that will optionally retry beforeEach hooks and add sleep in between retries. This is necessary to avoid flakiness that seems to be caused by port exhaustion in CI and a mishandling of the error by web3. (See web3/web3.js#3425 and web3/web3.js#926). - I've only added `beforeEachWithRetries` to the Attestations tests because this error appears there the most. We can add it elsewhere in the future as needed. ### Other changes None ### Tested To see that this works, search logs for "retry" in https://circleci.com/gh/celo-org/celo-monorepo/248635 ### Related issues - Fixes celo-org#4570 ### Backwards compatibility Not applicable
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
@uluhonolulu I have a PR in progress that addresses this, TODO is to get error codes thrown instead of strings. I don't have time to get around to finishing it right now, if you're still willing & able to help would be great if you could assist finishing it off #3426 |
@liamaharon I'll be happy to work on it. Do you think I'll be able to continue working on your PR (permissions?) or create a new one? (Sorry if it's a dumb question) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
@liamaharon Did you wind up being able to make any progress? It looks like you got an answer to that question on the PR! |
@spacesailor24 I promised to work on it, and I was planning to get it done over the weekend. |
The workaround here is to use WebsocketProvider, at least in the case of truffle tests |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Is the fix for this still in progress? |
@wbt I've created a pull request (#3947), but it didn't pass all tests (the same tests were failing before my changes), but then I stopped receiving notifications and missed the discussion there. Not sure what is the story with the @koraykoska's fix. |
* Improve http request error handling * Update changelog.md * Update mock response * Add error code to HTTP connection error * Propagate the original request error (#3425) * Fixed a test (#3425) Co-authored-by: Liam Aharon <[email protected]>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Will be addressed in 4.x http provider. |
I still got same error when use HttpProvider, any suggest? |
In the event of an error occurring during a XMLHttpRequest,
onreadystatechange
is called whenrequest.readyState
is4
request.responseText
is""
request.status
is0
The following code that handles http requests does not handle this case, and can return a misleading error to the user when it occurs
https://github.com/ethereum/web3.js/blob/dee72e00883c5a23a47b6d3c1d27304ab1d4922e/packages/web3-providers-http/src/index.js#L87-L125
Let's pretend a machine has exhausted all of it's ephemeral ports right before web3.js tries to send a request. Here's what happens
HttpProvider.prototype.send
is calledonreadystatechange
andontimeout
handlers are assignedrequest.send
is called with the payloadrequest.readyState
is set to4
,request.responseText
is set to""
,request.status
is set to0
and theonreadystatechange
handler is called""
and throws an error that looks like thisthis error is misleading because it indicates that the node successfully received the request and actually returned an empty string in response, when in reality the request never even made it to the node and an empty string is just the default value set on
request
in an error scenario.I believe this may be the cause of some other issues people have opened in the past like #3370 and #1919
I think it makes sense to at least add an
onerror
handler to therequest
, and in the case that a request fails the error thrown indicates that instead of a misleadingInvalidResponse
error.I'm working on a PR for this.
The text was updated successfully, but these errors were encountered: