From 6ba4ed99c42b4976902046625790698b490c3e0e Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Wed, 13 Dec 2017 15:05:57 -0800 Subject: Fix hanging requests by importing web3 last --- packages/kovan-faucets/src/ts/handler.ts | 7 ++++++- packages/kovan-faucets/src/ts/request_queue.ts | 5 +++++ packages/kovan-faucets/src/ts/zrx_request_queue.ts | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/kovan-faucets/src/ts/handler.ts b/packages/kovan-faucets/src/ts/handler.ts index d76a29514..1c6866a1c 100644 --- a/packages/kovan-faucets/src/ts/handler.ts +++ b/packages/kovan-faucets/src/ts/handler.ts @@ -1,6 +1,5 @@ import * as express from 'express'; import * as _ from 'lodash'; -import * as Web3 from 'web3'; import ProviderEngine = require('web3-provider-engine'); import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet'); import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker'); @@ -12,6 +11,12 @@ import {idManagement} from './id_management'; import {utils} from './utils'; import {ZRXRequestQueue} from './zrx_request_queue'; +// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang +// because they are using the wrong XHR package. +// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 +// tslint:disable-next-line:ordered-imports +import * as Web3 from 'web3'; + export class Handler { private etherRequestQueue: EtherRequestQueue; private zrxRequestQueue: ZRXRequestQueue; diff --git a/packages/kovan-faucets/src/ts/request_queue.ts b/packages/kovan-faucets/src/ts/request_queue.ts index 2a3fd4d03..0b5e66ae9 100644 --- a/packages/kovan-faucets/src/ts/request_queue.ts +++ b/packages/kovan-faucets/src/ts/request_queue.ts @@ -1,5 +1,10 @@ import * as _ from 'lodash'; import * as timers from 'timers'; + +// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang +// because they are using the wrong XHR package. +// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 +// tslint:disable-next-line:ordered-imports import * as Web3 from 'web3'; const MAX_QUEUE_SIZE = 500; diff --git a/packages/kovan-faucets/src/ts/zrx_request_queue.ts b/packages/kovan-faucets/src/ts/zrx_request_queue.ts index 72500789c..6e6590e7c 100644 --- a/packages/kovan-faucets/src/ts/zrx_request_queue.ts +++ b/packages/kovan-faucets/src/ts/zrx_request_queue.ts @@ -2,13 +2,18 @@ import {ZeroEx} from '0x.js'; import {promisify} from '@0xproject/utils'; import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; -import * as Web3 from 'web3'; import {configs} from './configs'; import {errorReporter} from './error_reporter'; import {RequestQueue} from './request_queue'; import {utils} from './utils'; +// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang +// because they are using the wrong XHR package. +// Issue: https://github.com/trufflesuite/truffle-contract/issues/14 +// tslint:disable-next-line:ordered-imports +import * as Web3 from 'web3'; + const DISPENSE_AMOUNT_ZRX = new BigNumber(0.1); const QUEUE_INTERVAL_MS = 5000; -- cgit v1.2.3