@exodus/bitcoin-api 4.14.4 → 4.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.14.5](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.14.4...@exodus/bitcoin-api@4.14.5) (2026-04-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* fix: enforce fetch timeouts in insight and mempool clients (#7854)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [4.14.4](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@4.14.3...@exodus/bitcoin-api@4.14.4) (2026-04-23)
|
|
7
17
|
|
|
8
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bitcoin-api",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.5",
|
|
4
4
|
"description": "Bitcoin transaction and fee monitors, RPC with the blockchain node, other networking code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c420214d58816a0f5aa682822b066309d796fe30"
|
|
67
67
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const isPositiveTimeout = (timeout) => Number.isFinite(timeout) && timeout > 0
|
|
2
|
+
|
|
3
|
+
export default async function fetchWithTimeout(url, fetchOptions) {
|
|
4
|
+
const { timeout, signal, ...restFetchOptions } = fetchOptions || Object.create(null)
|
|
5
|
+
const hasFetchOptions = signal !== undefined || Object.keys(restFetchOptions).length > 0
|
|
6
|
+
const normalizedFetchOptions = hasFetchOptions
|
|
7
|
+
? signal
|
|
8
|
+
? { ...restFetchOptions, signal }
|
|
9
|
+
: restFetchOptions
|
|
10
|
+
: undefined
|
|
11
|
+
|
|
12
|
+
if (!isPositiveTimeout(timeout) || typeof AbortController !== 'function') {
|
|
13
|
+
return fetch(url, normalizedFetchOptions)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const controller = new AbortController()
|
|
17
|
+
const abort = () => controller.abort()
|
|
18
|
+
const timeoutId = setTimeout(abort, timeout)
|
|
19
|
+
|
|
20
|
+
if (signal) {
|
|
21
|
+
if (signal.aborted) {
|
|
22
|
+
abort()
|
|
23
|
+
} else {
|
|
24
|
+
signal.addEventListener('abort', abort, { once: true })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
return await fetch(url, { ...restFetchOptions, signal: controller.signal })
|
|
30
|
+
} finally {
|
|
31
|
+
clearTimeout(timeoutId)
|
|
32
|
+
signal?.removeEventListener?.('abort', abort)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -5,6 +5,8 @@ import delay from 'delay'
|
|
|
5
5
|
import lodash from 'lodash'
|
|
6
6
|
import urlJoin from 'url-join'
|
|
7
7
|
|
|
8
|
+
import fetchWithTimeout from './fetch-with-timeout.js'
|
|
9
|
+
|
|
8
10
|
const { isEmpty } = lodash
|
|
9
11
|
|
|
10
12
|
const INSIGHT_HTTP_ERROR_MESSAGE = safeString`insight-api-http-error`
|
|
@@ -40,7 +42,7 @@ const fetchJson = async (
|
|
|
40
42
|
nullWhen404,
|
|
41
43
|
httpErrorMessage = INSIGHT_HTTP_ERROR_MESSAGE
|
|
42
44
|
) => {
|
|
43
|
-
const response = await
|
|
45
|
+
const response = await fetchWithTimeout(url, fetchOptions)
|
|
44
46
|
|
|
45
47
|
if (nullWhen404 && response.status === 404) {
|
|
46
48
|
return null
|
|
@@ -4,6 +4,8 @@ import { TraceId } from '@exodus/traceparent'
|
|
|
4
4
|
import delay from 'delay'
|
|
5
5
|
import urlJoin from 'url-join'
|
|
6
6
|
|
|
7
|
+
import fetchWithTimeout from './fetch-with-timeout.js'
|
|
8
|
+
|
|
7
9
|
const API_PAGE_SIZE = 25
|
|
8
10
|
const DEFAULT_PAGE_SIZE = 10
|
|
9
11
|
const RETRY_WAIT_TIMES = ['5s', '10s', '20s', '30s']
|
|
@@ -109,7 +111,7 @@ async function withRetry(fn, args = [], { waitTimes = RETRY_WAIT_TIMES } = {}) {
|
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
async function fetchJson(url, fetchOptions, { nullWhen404 = false, httpErrorMessage } = {}) {
|
|
112
|
-
const response = await
|
|
114
|
+
const response = await fetchWithTimeout(url, fetchOptions)
|
|
113
115
|
if (nullWhen404 && response.status === 404) {
|
|
114
116
|
return null
|
|
115
117
|
}
|
|
@@ -132,7 +134,7 @@ async function fetchJson(url, fetchOptions, { nullWhen404 = false, httpErrorMess
|
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
async function fetchText(url, fetchOptions, { nullWhen404 = false, httpErrorMessage } = {}) {
|
|
135
|
-
const response = await
|
|
137
|
+
const response = await fetchWithTimeout(url, fetchOptions)
|
|
136
138
|
if (nullWhen404 && response.status === 404) {
|
|
137
139
|
return null
|
|
138
140
|
}
|