Skip to content

Commit

Permalink
fix(utils): cancel fetch request if response is not ok
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Feb 27, 2024
1 parent 928eec4 commit 0060e4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/thirdweb/src/chains/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export function getChainDataForChain(chain: Chain): Promise<ApiChain> {
async () => {
const res = await fetch(`https://api.thirdweb.com/v1/chains/${chainId}`);
if (!res.ok) {
res.body?.cancel();
throw new Error(`Failed to fetch chain data for chainId ${chainId}`);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/thirdweb/src/utils/signatures/resolve-signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function resolveFunctionSignature(
`${SIGNATURE_API}/signatures/?format=json&hex_signature=${hexSig}`,
);
if (!res.ok) {
res.body?.cancel();
console.log(res.statusText);
return null;
}
Expand All @@ -39,6 +40,7 @@ async function resolveEventSignature(
`${SIGNATURE_API}/event-signatures/?format=json&hex_signature=${hexSig}`,
);
if (!res.ok) {
res.body?.cancel();
console.log(res.statusText);
return null;
}
Expand Down

0 comments on commit 0060e4b

Please sign in to comment.