Skip to content

Commit

Permalink
Merge pull request #16 from defer-run/fix/polling-error-result
Browse files Browse the repository at this point in the history
  • Loading branch information
charlypoly authored Jan 2, 2023
2 parents 32cf355 + e282ee3 commit 2b8d060
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-steaks-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@defer.run/client": patch
---

Handle error without result on polling
4 changes: 2 additions & 2 deletions src/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function serializeBackgroundFunctionArguments(
export interface DeferExecutionResponse {
id: string;
state: "running" | "created" | "failed" | "succeed";
result: any;
result?: any;
}

const jitter = (attempt: number) =>
Expand Down Expand Up @@ -155,7 +155,7 @@ export function poolForExecutionResult<R>(
return;
} else if (result.state === "failed") {
let error = new Error("Defer execution failed");
if (result.result.message) {
if (result.result?.message) {
error = new Error(result.result.message);
error.stack = result.result.stack;
} else if (result.result) {
Expand Down

0 comments on commit 2b8d060

Please sign in to comment.