diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-13 18:05:02 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-13 18:05:02 +0800 |
commit | 1229c61ba420b280708b39c04cc21f31e43ed3cf (patch) | |
tree | c7786e908bad147d6dd44962e0edd0571bdaac18 /packages | |
parent | c2a1317c3813b13353eb84e4255284fe99ff8e6c (diff) | |
download | dexon-sol-tools-1229c61ba420b280708b39c04cc21f31e43ed3cf.tar.gz dexon-sol-tools-1229c61ba420b280708b39c04cc21f31e43ed3cf.tar.zst dexon-sol-tools-1229c61ba420b280708b39c04cc21f31e43ed3cf.zip |
Make timeout configurable on RPCSubprovider
Diffstat (limited to 'packages')
-rw-r--r-- | packages/subproviders/src/subproviders/rpc_subprovider.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/subproviders/src/subproviders/rpc_subprovider.ts b/packages/subproviders/src/subproviders/rpc_subprovider.ts index 0fb99f87a..5c1c3272c 100644 --- a/packages/subproviders/src/subproviders/rpc_subprovider.ts +++ b/packages/subproviders/src/subproviders/rpc_subprovider.ts @@ -14,10 +14,12 @@ import { Subprovider } from './subprovider'; */ export class RPCSubprovider extends Subprovider { private _rpcUrl: string; - constructor(rpcUrl: string) { + private _requestTimeoutMs: number; + constructor(rpcUrl: string, requestTimeoutMs: number = 20000) { super(); assert.isString('rpcUrl', rpcUrl); this._rpcUrl = rpcUrl; + this._requestTimeoutMs = requestTimeoutMs; } /** * This method conforms to the web3-provider-engine interface. @@ -35,9 +37,6 @@ export class RPCSubprovider extends Subprovider { 'Content-Type': 'application/json', }); - // Since Ethereum nodes have a proclivity for accepting requests and never - // returning a response, we set this quite low (10 seconds). - const timeoutMs = 10000; let response; try { response = await fetchAsync( @@ -47,7 +46,7 @@ export class RPCSubprovider extends Subprovider { headers, body: JSON.stringify(finalPayload), }, - timeoutMs, + this._requestTimeoutMs, ); } catch (err) { end(new JsonRpcError.InternalError(err)); |