From 81297b44c6392e1cb995848a5f81bdc3ce6108be Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 6 Oct 2017 13:15:11 +0300 Subject: Add undefined check --- src/contract_wrappers/contract_wrapper.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts index 492d40a28..f6ccfdee4 100644 --- a/src/contract_wrappers/contract_wrapper.ts +++ b/src/contract_wrappers/contract_wrapper.ts @@ -123,6 +123,9 @@ export class ContractWrapper { private async _reconcileBlockAsync(): Promise { const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest); // We need to coerce to Block type cause Web3.Block includes types for mempool blocks - (this._blockAndLogStreamer as BlockAndLogStreamer).reconcileNewBlock(latestBlock as any as Block); + if (!_.isUndefined(this._blockAndLogStreamer)) { + // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined + this._blockAndLogStreamer.reconcileNewBlock(latestBlock as any as Block); + } } } -- cgit v1.2.3