Skip to content

Commit

Permalink
Fix blink body consumed before we use it
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Nov 20, 2024
1 parent 856014e commit 119350b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions wallets/blink/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertContentTypeJson, assertResponseOk } from '@/lib/url'
import { assertContentTypeJson } from '@/lib/url'

export const galoyBlinkUrl = 'https://api.blink.sv/graphql'
export const galoyBlinkDashboardUrl = 'https://dashboard.blink.sv/'
Expand Down Expand Up @@ -40,11 +40,12 @@ export async function request (authToken, query, variables = {}) {
}
const res = await fetch(galoyBlinkUrl, options)

// consume response body to avoid memory leaks
// see https://github.com/nodejs/node/issues/51162
res.text().catch(() => {})

assertResponseOk(res)
if (!res.ok) {
// consume response body to avoid memory leaks
// see https://github.com/nodejs/node/issues/51162
res.text().catch(() => {})
throw new Error(`POST ${res.url}: ${res.status} ${res.statusText}`)
}
assertContentTypeJson(res)

return res.json()
Expand Down

0 comments on commit 119350b

Please sign in to comment.