Skip to content

Commit

Permalink
Fix parsing of non-eth_subscription provider events (#3660)
Browse files Browse the repository at this point in the history
* fix parsing provider subscription by checking for result.params.subscripton, as other non-subscription events may come down the pipe

* add to changelog
  • Loading branch information
ryanio authored Jul 28, 2020
1 parent bf06daa commit 6cae35d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,4 @@ Released with 1.0.0-beta.37 code base.

### Fixed

- Fix parsing of non-`eth_subscription` provider events (#3660)
4 changes: 2 additions & 2 deletions packages/web3-core-requestmanager/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ RequestManager.prototype.setProvider = function (provider, net) {
this.provider.on('data', function data(result, deprecatedResult) {
result = result || deprecatedResult; // this is for possible old providers, which may had the error first handler

// check for result.method, to prevent old providers errors to pass as result
if (result.method && _this.subscriptions.has(result.params.subscription)) {
// if result is a subscription, call callback for that subscription
if (result.method && result.params && result.params.subscription && _this.subscriptions.has(result.params.subscription)) {
_this.subscriptions.get(result.params.subscription).callback(null, result.params.result);
}
});
Expand Down

0 comments on commit 6cae35d

Please sign in to comment.