mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
270d1d0fa9
We had forgotten to add `eslint` as a dependency, even though we use it directly. It had always worked because we have dependencies that also depend upon it. `eslint` has also been updated to v6, which necessitated two minor changes.
24 lines
593 B
JavaScript
24 lines
593 B
JavaScript
export default function ({ timeout = 120000 } = {}) {
|
|
return function _fetch (url, opts) {
|
|
return new Promise(async (resolve, reject) => {
|
|
const abortController = new AbortController()
|
|
const abortSignal = abortController.signal
|
|
const f = fetch(url, {
|
|
...opts,
|
|
signal: abortSignal,
|
|
})
|
|
|
|
const timer = setTimeout(() => abortController.abort(), timeout)
|
|
|
|
try {
|
|
const res = await f
|
|
clearTimeout(timer)
|
|
return resolve(res)
|
|
} catch (e) {
|
|
clearTimeout(timer)
|
|
return reject(e)
|
|
}
|
|
})
|
|
}
|
|
}
|