Skip to content

Commit

Permalink
Merge pull request #3531 from ethereum/issue/3257
Browse files Browse the repository at this point in the history
Fix eth.clearSubscriptions size property de-referencing bug
  • Loading branch information
ryanio authored May 23, 2020
2 parents 53e4cab + 5c60d1f commit 6720ec0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,5 @@ Released with 1.0.0-beta.37 code base.
### Changed

### Fixed

- Fix size property de-referencing crash when calling web3.eth.clearSubscriptions (#3527)
2 changes: 1 addition & 1 deletion packages/web3-eth/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ var Eth = function Eth() {
});


this.clearSubscriptions = _this._requestManager.clearSubscriptions;
this.clearSubscriptions = _this._requestManager.clearSubscriptions.bind(_this._requestManager);

// add net
this.net = new Net(this);
Expand Down
9 changes: 9 additions & 0 deletions test/eth.subscribe.ganache.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ describe('subscription connect/reconnect', function () {
});
});

it('clearSubscriptions', async function() {
web3.eth.subscribe('newBlockHeaders');
await waitSeconds(1); // Sub need a little time to set up

assert.equal(1, web3.eth._requestManager.subscriptions.size);
web3.eth.clearSubscriptions();
assert.equal(0, web3.eth._requestManager.subscriptions.size);
});

it('resubscribes to an existing subscription', function (done) {
this.timeout(5000);

Expand Down

0 comments on commit 6720ec0

Please sign in to comment.