Skip to content

Commit 7cc064e

Browse files
authored
fix: throw original error in pRetry (#174)
1 parent da36985 commit 7cc064e

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.36.0 (六月 06, 2025)
2+
3+
- fix: throw original error in pRetry
4+
15
## 0.35.1 (六月 05, 2025)
26

37
- feat: always retry for 5xx errors

packages/sdk-util/src/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,23 @@ class BaseClient {
320320
message = `GraphQLError: ${message}`;
321321
}
322322

323-
const err = res.status >= 500 ? new Error(message) : new pRetry.AbortError(message);
324-
err.errors = json.errors;
325-
err.status = res.status;
323+
const originalError = new Error(message);
324+
originalError.errors = json.errors;
325+
originalError.status = res.status;
326+
327+
const err = res.status >= 500 ? originalError : new pRetry.AbortError(originalError);
326328
throw err;
327329
}
328330

329331
// Handle HTTP errors
330332
if (res.status !== 200) {
331333
const message = json.error || json.message || `GraphQL Status Error ${res.status}`;
332-
const err = res.status >= 500 ? new Error(message) : new pRetry.AbortError(message);
333-
err.status = res.status;
334-
err.response = json;
334+
335+
const originalError = new Error(message);
336+
originalError.status = res.status;
337+
originalError.response = json;
338+
339+
const err = res.status >= 500 ? originalError : new pRetry.AbortError(originalError);
335340
throw err;
336341
}
337342

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.35.1
1+
0.36.0

0 commit comments

Comments
 (0)