@exodus/bitcoin-api 5.0.5 → 5.0.6

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,15 @@
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
+ ## [5.0.6](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.0.5...@exodus/bitcoin-api@5.0.6) (2026-10-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **bitcoin-api:** retry rate-limited mempool reads ([#8874](https://github.com/ExodusMovement/assets/issues/8874)) ([5636aac](https://github.com/ExodusMovement/assets/commit/5636aacb50663b3faac2887e67a1e78a3b81f86d))
12
+
13
+
14
+
6
15
  ## [5.0.5](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@5.0.4...@exodus/bitcoin-api@5.0.5) (2026-10-06)
7
16
 
8
17
 
package/README.md CHANGED
@@ -12,7 +12,7 @@ Confirmation checks recheck their inputs if a WebSocket update, disconnect, or b
12
12
 
13
13
  Every HTTP 429 starts a process-local cooldown shared across clients and endpoints on the same origin. Valid `Retry-After` seconds or HTTP dates take precedence, using the server's `Date` header for clock skew when available, and are capped at five minutes. Missing or invalid values use a ten-second fallback; failed recovery doubles it with 0–20% positive jitter, also capped at five minutes. Concurrent responses from the original burst do not multiply backoff, but longer server deadlines are preserved.
14
14
 
15
- The dispatched request fails with code `429`, `finalError`, bounded `retryAt`/`retryAfterMs`, and hint `mempoolRateLimited`; generic retries stop. Queued reads wait until one recovery read can run, with a ten-second timeout including its body. Success or an ordinary 404 releases the cooldown; other HTTP, transport, or body failures renew it. No recovery request is generated when the queue is empty.
15
+ Reads receiving HTTP 429 rejoin the end of the queue instead of immediately failing the monitor scan. Each read permits at most two retries, sharing its original 30-second queue deadline; cancellation, overflow, or expiry still fail finally. Exhausted retries fail with code `429`, `finalError`, bounded `retryAt`/`retryAfterMs`, and hint `mempoolRateLimited`; generic retries stop. Queued reads wait until one recovery read can run, with a ten-second timeout including its body. Success or an ordinary 404 releases the cooldown; other HTTP, transport, or body failures renew it. No recovery request is generated when the queue is empty.
16
16
 
17
17
  ## Mempool request scheduling
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
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",
@@ -59,5 +59,5 @@
59
59
  "type": "git",
60
60
  "url": "git+https://github.com/ExodusMovement/assets.git"
61
61
  },
62
- "gitHead": "fb42d6502575a15419bff613b88aed10d2be8529"
62
+ "gitHead": "9b46bc04b11bba7921cd542a5788bf6430c482c5"
63
63
  }
@@ -4,6 +4,7 @@ const MAX_ACTIVE_REQUESTS = 2
4
4
  const REQUEST_INTERVAL_MS = 200
5
5
  const MAX_QUEUED_REQUESTS = 100
6
6
  const MAX_QUEUE_WAIT_MS = 30_000
7
+ const MAX_READ_RETRIES = 2
7
8
  const schedulersByOrigin = new Map()
8
9
 
9
10
  const createAbortError = (signal) => {
@@ -67,12 +68,12 @@ const drain = (origin) => {
67
68
 
68
69
  export const resumeMempoolRequests = (origin) => drain(origin)
69
70
 
70
- export default function scheduleMempoolRequest(
71
- origin,
72
- execute,
73
- { signal, isBroadcast, getCooldown } = {}
74
- ) {
71
+ function enqueueMempoolRequest(origin, execute, { signal, isBroadcast, getCooldown, expiresAt }) {
75
72
  if (signal?.aborted) return Promise.reject(createAbortError(signal))
73
+ const maxWaitMs = expiresAt - Date.now()
74
+ if (maxWaitMs <= 0) {
75
+ return Promise.reject(createQueueError('MEMPOOL_REQUEST_QUEUE_TIMEOUT'))
76
+ }
76
77
  let scheduler = schedulersByOrigin.get(origin)
77
78
  if (!scheduler) {
78
79
  scheduler = { active: 0, timer: null, wakeTimer: null, queue: [], getCooldown }
@@ -87,12 +88,11 @@ export default function scheduleMempoolRequest(
87
88
  }
88
89
 
89
90
  return new Promise((resolve, reject) => {
90
- const maxWaitMs = isBroadcast ? 1000 : MAX_QUEUE_WAIT_MS
91
91
  const entry = {
92
92
  execute,
93
93
  resolve,
94
94
  reject,
95
- expiresAt: Date.now() + maxWaitMs,
95
+ expiresAt,
96
96
  cleanup: () => {
97
97
  clearTimeout(timeout)
98
98
  signal?.removeEventListener('abort', onAbort)
@@ -119,3 +119,14 @@ export default function scheduleMempoolRequest(
119
119
  drain(origin)
120
120
  })
121
121
  }
122
+
123
+ export default async function scheduleMempoolRequest(origin, execute, options = {}) {
124
+ const expiresAt = Date.now() + (options.isBroadcast ? 1000 : MAX_QUEUE_WAIT_MS)
125
+ for (let attempt = 0; ; attempt++) {
126
+ try {
127
+ return await enqueueMempoolRequest(origin, execute, { ...options, expiresAt })
128
+ } catch (error) {
129
+ if (options.isBroadcast || error?.code !== '429' || attempt >= MAX_READ_RETRIES) throw error
130
+ }
131
+ }
132
+ }