From 119350b916706bb78904aa57f2117d2775332aac Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 20 Nov 2024 18:13:09 +0100 Subject: [PATCH] Fix blink body consumed before we use it --- wallets/blink/common.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wallets/blink/common.js b/wallets/blink/common.js index d43449878..ee95b1671 100644 --- a/wallets/blink/common.js +++ b/wallets/blink/common.js @@ -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/' @@ -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()