Skip to content

Commit

Permalink
worker: typings
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Nov 15, 2023
1 parent 8587600 commit 2f930c0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/ws-worker/src/api/reasons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { AttemptState } from './execute';
import type { ExitReason, ExitReasonStrings, State } from '../types';
import type {
ExitReason,
ExitReasonStrings,
State,
AttemptState,
} from '../types';

import type { JobNode } from '@openfn/runtime';

Expand Down Expand Up @@ -43,11 +47,11 @@ const calculateAttemptExitReason = (state: AttemptState) => {
// basically becomes the exit reason
// So If we get here, we basically just need to look to see if there's a fail on a leaf node
// (we ignore fails on non-leaf nodes)
const leafJobReasons = state.plan.jobs
.filter((job) => isLeafNode(state, job))
const leafJobReasons: ExitReason[] = state.plan.jobs
.filter((job: JobNode) => isLeafNode(state, job))
// TODO what if somehow there is no exit reason for a job?
// This implies some kind of exception error, no?
.map(({ id }) => state.reasons[id!]);
.map(({ id }: JobNode) => state.reasons[id!]);

const fail = leafJobReasons.find((r) => r && r.reason === 'fail');
if (fail) {
Expand Down

0 comments on commit 2f930c0

Please sign in to comment.