Skip to content

Commit

Permalink
fix: gracefully handle golem activity state check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha87 committed Feb 15, 2024
1 parent 4ae17c8 commit 3b0df73
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/golem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,22 @@ export class Golem {
// Or did the terminate fail and the SDK does not send that?
},
validate: async (activity: Activity) => {
const state = await activity.getState();
const result = state !== ActivityStateEnum.Terminated;
this.logger(
"Validating activity in the pool, result: %s, state: %s",
result,
state,
);
return result;
try {
const state = await activity.getState();
const result = state !== ActivityStateEnum.Terminated;
this.logger(
"Validating activity in the pool, result: %s, state: %s",
result,
state,
);
return result;
} catch (err) {
this.logger(
"Checking activity status failed. The activity will be removed from the pool. Error: %o",
err,
);
return false;
}
},
},
{
Expand Down

0 comments on commit 3b0df73

Please sign in to comment.