Skip to content

Commit

Permalink
Fix abort handling in dynamo fetch
Browse files Browse the repository at this point in the history
If a reason is provided to the abort method of AbortController, it will be thrown directly. It will not be wrapped in an AbortError.

This could alternatively be fixed by aborting with Error objects, but this is the simpler method.
  • Loading branch information
erlend-amdal-adsk committed Mar 11, 2024
1 parent 62e6773 commit 1ae9918
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions analyses/constraints/src/dynamo/dynamo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ export async function run(code, state) {

return { data: await response.json(), type: "success" };
} catch (e) {
if (e.name === "AbortError") {
if (signal.reason === "aborting previous request") {
return { type: "aborted" };
} else {
throw Error("Request timed out after 30 seconds");
}
if (e === "aborting previous request") {
return { type: "aborted" };
} else if (e === "timeout") {
throw Error("Request timed out after 30 seconds");
} else {
throw e;
}
Expand Down

0 comments on commit 1ae9918

Please sign in to comment.