Skip to content

Commit

Permalink
Propagate the original request error (web3#3425)
Browse files Browse the repository at this point in the history
  • Loading branch information
uluhonolulu committed Mar 10, 2021
1 parent e348e88 commit 0f518c9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/web3-providers-http/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,15 @@ HttpProvider.prototype.send = function (payload, callback) {
}
};

request.onerror = function() {
callback(errors.RequestFailed());
};
//since XHR2._onHttpRequestError swallows the initial request error, we need to get it from the underlying request
request.addEventListener('loadstart', function() {
var clientRequest = request._request;
if (clientRequest) {
clientRequest.on('error', function (error) {
callback(error || errors.RequestFailed());
});
}
});

request.ontimeout = function() {
_this.connected = false;
Expand Down

0 comments on commit 0f518c9

Please sign in to comment.