-
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
Feature/improve xml request error handling #3426
Feature/improve xml request error handling #3426
Conversation
@@ -111,6 +111,10 @@ HttpProvider.prototype.send = function (payload, callback) { | |||
} | |||
}; | |||
|
|||
request.onerror = function() { | |||
callback(errors.RequestFailed()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be great to get our users some more information about the failed requests. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed :)
I wrote a little bit about this towards the end of the PR description, would you be open to having XMLHttpRequest
being replaced with another library like fetch
as part of this PR?
Would it be too much to ask to request an error number be included, instead of just an error string, to avoid upgrade issues like this with future string clarifications? |
This would be nice to revive, @liamaharon do you mind updating your branch accordingly and we can take a look at it :) |
…quest-error-handling
@wbt I think this is sensible. The easiest (and laziest) way to implement this would be to add a prefix or suffix to all the error strings, for example something like @GregTheGreek sure, I've merged the latest |
That still seems a bit hacky. In more professionalized packages, the errors thrown are objects rather than strings, with members "message" (the existing error message), "code" (a numeric code), and sometimes other fields. I was thinking along those lines. |
This PR has been automatically marked as stale beacause 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. |
Please don't close it, the current error message is too confusing and requires very specific know-how to understand. |
This PR has been automatically marked as stale beacause 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 LOL; bots apparently don't read. |
@GregTheGreek I would like to pick up this PR as @liamaharon asked me. The only problem is I've never worked on somebody else's PR's, so I don't know how to do it technically. Should I open a new PR or contribute to this one somehow? If the latter, can you assign it to me, please? |
I would branch off of this pr and open a new one! |
OK, I'm on it |
|
This PR has been automatically marked as stale beacause 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. |
Closing this PR in favor of #3425 (comment) |
Description
Adds explicit handling for XMLHttpRequest errors.
When an XMLHttpRequest fails, instead of throwing
Error: Invalid JSON RPC response: ""
throwError: HTTP request failed
.Unfortunately, accessing the specifics about what caused a request error when using
XMLHttpRequest
is not trivial.In future versions of web3.js maybe
XMLHttpRequest
could be substituted for fetch, which is built into modern browsers (so no increase to bundle size). As well making informative error handling really simple, a Fetch implementation would require far fewer lines of code and less complexity in the packages/web3-providers-http/src/index.js file.Fixes #3425
Type of change
Checklist:
npm run dtslint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:cov
and my test cases do cover all lines and branches of the added code. Unsure if required to write tests for this change as there don't appear to be tests for similar logic branches, happy to if it's required just let me knownpm run build-all
and tested the resulting file/'s fromdist
folder in a browser.CHANGELOG.md
file in the root folder. Did I do this right?First time opening a PR here so let me know if I made any mistakes, happy to revise ✌️