Set default getFetchWithTimeout default timeout value (#14218)

feature/default_network_editable
David Walsh 2 years ago committed by GitHub
parent 7d321c48e0
commit 95adbc245c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/scripts/controllers/incoming-transactions.js
  2. 3
      app/scripts/controllers/network/network.js
  3. 3
      app/scripts/lib/buy-url.js
  4. 3
      app/scripts/lib/ens-ipfs/setup.js
  5. 3
      app/scripts/lib/network-store.js
  6. 3
      shared/modules/fetch-with-timeout.js
  7. 8
      shared/modules/fetch-with-timeout.test.js
  8. 3
      shared/modules/rpc.utils.js
  9. 3
      ui/helpers/utils/i18n-helper.js

@ -18,9 +18,8 @@ import {
RINKEBY_CHAIN_ID,
ROPSTEN_CHAIN_ID,
} from '../../../shared/constants/network';
import { SECOND } from '../../../shared/constants/time';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
/**
* @typedef {import('../../../shared/constants/transaction').TransactionMeta} TransactionMeta

@ -20,7 +20,6 @@ import {
INFURA_BLOCKED_KEY,
TEST_NETWORK_TICKER_MAP,
} from '../../../../shared/constants/network';
import { SECOND } from '../../../../shared/constants/time';
import {
isPrefixedFormattedHexString,
isSafeChainId,
@ -31,7 +30,7 @@ import createInfuraClient from './createInfuraClient';
import createJsonRpcClient from './createJsonRpcClient';
const env = process.env.METAMASK_ENV;
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
let defaultProviderConfigOpts;
if (process.env.IN_TEST) {

@ -9,7 +9,6 @@ import {
ROPSTEN_CHAIN_ID,
BUYABLE_CHAINS_MAP,
} from '../../../shared/constants/network';
import { SECOND } from '../../../shared/constants/time';
import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout';
import {
TRANSAK_API_KEY,
@ -17,7 +16,7 @@ import {
COINBASEPAY_API_KEY,
} from '../constants/on-ramp';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
/**
* Create a Wyre purchase URL.

@ -2,11 +2,10 @@ import base32Encode from 'base32-encode';
import base64 from 'base64-js';
import browser from 'webextension-polyfill';
import { SECOND } from '../../../../shared/constants/time';
import getFetchWithTimeout from '../../../../shared/modules/fetch-with-timeout';
import resolveEnsToIpfsContentId from './resolver';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
const supportedTopLevelDomains = ['eth'];

@ -1,8 +1,7 @@
import log from 'loglevel';
import { SECOND } from '../../../shared/constants/time';
import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
const FIXTURE_SERVER_HOST = 'localhost';
const FIXTURE_SERVER_PORT = 12345;

@ -1,6 +1,7 @@
import { memoize } from 'lodash';
import { SECOND } from '../constants/time';
const getFetchWithTimeout = memoize((timeout) => {
const getFetchWithTimeout = memoize((timeout = SECOND * 30) => {
if (!Number.isInteger(timeout) || timeout < 1) {
throw new Error('Must specify positive integer timeout.');
}

@ -6,7 +6,7 @@ describe('getFetchWithTimeout', () => {
it('fetches a url', async () => {
nock('https://api.infura.io').get('/money').reply(200, '{"hodl": false}');
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
const response = await (
await fetchWithTimeout('https://api.infura.io/money')
).json();
@ -46,15 +46,9 @@ describe('getFetchWithTimeout', () => {
});
it('throws on invalid timeout', async () => {
await expect(() => getFetchWithTimeout()).toThrow(
'Must specify positive integer timeout.',
);
await expect(() => getFetchWithTimeout(-1)).toThrow(
'Must specify positive integer timeout.',
);
await expect(() => getFetchWithTimeout({})).toThrow(
'Must specify positive integer timeout.',
);
await expect(() => getFetchWithTimeout(true)).toThrow(
'Must specify positive integer timeout.',
);

@ -1,7 +1,6 @@
import { SECOND } from '../constants/time';
import getFetchWithTimeout from './fetch-with-timeout';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
/**
* Makes a JSON RPC request to the given URL, with the given RPC method and params.

@ -3,10 +3,9 @@ import React from 'react';
import log from 'loglevel';
import * as Sentry from '@sentry/browser';
import { SECOND } from '../../../shared/constants/time';
import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout';
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
const fetchWithTimeout = getFetchWithTimeout();
const warned = {};
const missingMessageErrors = {};

Loading…
Cancel
Save