Skip to content

Commit a079a74

Browse files
authored
fix: regression in 'NoEstimateAvailable' check (#1785)
* fix: regression in 'NoEstimateAvailable' check * ci: bump nodejs version * chore: lint fix
1 parent 1d7d280 commit a079a74

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/transactions/src/fetch.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,16 @@ export async function fetchFeeEstimateTransaction({
197197
const response = await client.fetch(url, options);
198198

199199
if (!response.ok) {
200-
const body = await response.json().catch(() => ({}));
201-
202-
if (body?.reason === 'NoEstimateAvailable') {
203-
throw new NoEstimateAvailableError(body?.reason_data?.message ?? '');
200+
const body = await response.text().catch(() => '');
201+
202+
if (body.includes('NoEstimateAvailable')) {
203+
let json: { reason_data?: { message?: string } } = {};
204+
try {
205+
json = JSON.parse(body);
206+
} catch (err) {
207+
// ignore
208+
}
209+
throw new NoEstimateAvailableError(json?.reason_data?.message ?? '');
204210
}
205211

206212
throw new Error(

0 commit comments

Comments
 (0)