Skip to content

Commit ef6b4f4

Browse files
committed
Add reason string on abort() method in fetch util (#5063)
Fixes: DASH-323 <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on improving error handling in the `abort` method of the `AbortController` by adding a reason string. This change aims to prevent the `AbortError: signal is aborted without reason` errors and updates tests to reflect the new error message. ### Detailed summary - Updated the `abort` method in `fetch.ts` to include a reason string: `controller?.abort("timeout")`. - Changed the expected error message in `download.test.ts` from "This operation was aborted" to "timeout" for two test cases. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent c5a2cdb commit ef6b4f4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/serious-masks-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Add reason string on abort controller's `abort` method to avoid `AbortError: signal is aborted without reason` errors

packages/thirdweb/src/storage/download.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe("download", () => {
106106
uri: "ipfs://QmTest1234567890TestHash/file.txt",
107107
requestTimeoutMs: 500,
108108
}),
109-
).rejects.toThrow("This operation was aborted");
109+
).rejects.toThrow("timeout");
110110
});
111111

112112
it("should respect custom client timeout", async () => {
@@ -125,6 +125,6 @@ describe("download", () => {
125125
},
126126
uri: "ipfs://QmTest1234567890TestHash/file.txt",
127127
}),
128-
).rejects.toThrow("This operation was aborted");
128+
).rejects.toThrow("timeout");
129129
});
130130
});

packages/thirdweb/src/utils/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
7272
if (requestTimeoutMs) {
7373
controller = new AbortController();
7474
abortTimeout = setTimeout(() => {
75-
controller?.abort();
75+
controller?.abort("timeout");
7676
}, requestTimeoutMs);
7777
}
7878

0 commit comments

Comments
 (0)