diff --git a/packages/web3-core-requestmanager/src/index.js b/packages/web3-core-requestmanager/src/index.js index 97b07c9fded..21478c69d07 100644 --- a/packages/web3-core-requestmanager/src/index.js +++ b/packages/web3-core-requestmanager/src/index.js @@ -131,11 +131,11 @@ RequestManager.prototype.setProvider = function (provider, net) { _this.subscriptions.delete(subscription.subscription.id); }); - if(_this.provider.emit){ + if(_this.provider && _this.provider.emit){ _this.provider.emit('error', errors.ConnectionCloseError(event)); } } - if(_this.provider.emit){ + if(_this.provider && _this.provider.emit){ _this.provider.emit('end', event); } });