diff --git a/CHANGELOG.md b/CHANGELOG.md index 7366801d8fb..639007fcac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,3 +113,5 @@ Released with 1.0.0-beta.37 code base. - ``eth-lib`` dependency updated (0.2.7 => 0.2.8) (#3242) ### Fixed + +- ``clearSubscriptions`` does no longer throw an error if no running subscriptions do exist (#3246) diff --git a/packages/web3-core-requestmanager/src/index.js b/packages/web3-core-requestmanager/src/index.js index 4fc48d493c7..4bff56b5ea3 100644 --- a/packages/web3-core-requestmanager/src/index.js +++ b/packages/web3-core-requestmanager/src/index.js @@ -228,11 +228,13 @@ RequestManager.prototype.clearSubscriptions = function (keepIsSyncing) { var _this = this; - // uninstall all subscriptions - Object.keys(this.subscriptions).forEach(function(id){ - if(!keepIsSyncing || _this.subscriptions[id].name !== 'syncing') - _this.removeSubscription(id); - }); + if (this.subscriptions) { + // uninstall all subscriptions + Object.keys(this.subscriptions).forEach(function(id){ + if(!keepIsSyncing || _this.subscriptions[id].name !== 'syncing') + _this.removeSubscription(id); + }); + } // reset notification callbacks etc.