Skip to content

Commit

Permalink
Merge pull request #793 from OpenFn/include-timestamp-on-job-error
Browse files Browse the repository at this point in the history
engine: Include timestamp on `JOB_ERROR`
  • Loading branch information
josephjclark authored Oct 1, 2024
2 parents 9e845b0 + 83a94ad commit 15763ed
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 4 deletions.
9 changes: 9 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/integration-tests-worker

## 1.0.62

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/engine-multi@1.3.0
- @openfn/ws-worker@1.7.0
- @openfn/lightning-mock@2.0.20

## 1.0.61

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.61",
"version": "1.0.62",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
6 changes: 6 additions & 0 deletions packages/engine-multi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# engine-multi

## 1.3.0

### Minor Changes

- ae55a6a: Include timestamp on JOB_ERROR payload

## 1.2.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/engine-multi",
"version": "1.2.5",
"version": "1.3.0",
"description": "Multi-process runtime engine",
"main": "dist/index.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions packages/engine-multi/src/api/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const jobError = (
duration,
jobId,
next,
time: timestamp(),
});
};

Expand Down
1 change: 1 addition & 0 deletions packages/engine-multi/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface JobCompletePayload extends ExternalEvent {
export interface JobErrorPayload extends ExternalEvent {
jobId: string;
duration: number;
time: bigint;
state: any; // the result state
error: any;
next: string[]; // downstream jobs
Expand Down
44 changes: 44 additions & 0 deletions packages/engine-multi/test/api/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
jobStart,
jobComplete,
error,
jobError,
} from '../../src/api/lifecycle';
import { WorkflowState } from '../../src/types';
import ExecutionContext from '../../src/classes/ExecutionContext';
Expand Down Expand Up @@ -194,6 +195,49 @@ test(`job-complete: emits ${e.JOB_COMPLETE} with key fields`, (t) => {
});
});

test(`job-error: emits ${e.JOB_ERROR} with key fields`, (t) => {
return new Promise((done) => {
const workflowId = 'a';

const state = {
id: workflowId,
startTime: Date.now() - 1000,
} as WorkflowState;

const context = createContext(workflowId, state);

const event: w.JobErrorEvent = {
type: w.JOB_ERROR,
error: {
message: 'Unexpected content returned',
name: 'JobError',
severity: 'fail',
},
workflowId,
threadId: '1',
jobId: 'j',
duration: 2,
state: 22,
next: [],
};

context.on(e.JOB_ERROR, (evt) => {
t.is(evt.workflowId, workflowId);
t.is(evt.threadId, '1');
t.is(evt.jobId, 'j');
t.is(evt.state, 22);
t.is(evt.duration, 2);
t.deepEqual(evt.next, []);
t.deepEqual(evt.error, event.error);
t.assert(evt.time > 0);
t.assert(typeof evt.time === 'bigint');
done();
});

jobError(context, event);
});
});

test(`log: emits ${e.WORKFLOW_LOG}`, (t) => {
return new Promise((done) => {
const workflowId = 'a';
Expand Down
7 changes: 7 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/lightning-mock

## 2.0.20

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/engine-multi@1.3.0

## 2.0.19

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.0.19",
"version": "2.0.20",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
11 changes: 11 additions & 0 deletions packages/ws-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ws-worker

## 1.7.0

### Minor Changes

- ae55a6a: Include timestamp on step complete even if the step failed

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/engine-multi@1.3.0

## 1.6.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ws-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/ws-worker",
"version": "1.6.7",
"version": "1.7.0",
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
"main": "dist/index.js",
"type": "module",
Expand Down

0 comments on commit 15763ed

Please sign in to comment.