From 1c41776f4e0fa2ac8791ed22eb15ef6bd8a070f3 Mon Sep 17 00:00:00 2001 From: Joe Clark Date: Sun, 12 Nov 2023 14:40:02 +0000 Subject: [PATCH 1/2] runtime: serialize final state before notifying it --- packages/runtime/src/execute/expression.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime/src/execute/expression.ts b/packages/runtime/src/execute/expression.ts index da9a914e8..97091cc0d 100644 --- a/packages/runtime/src/execute/expression.ts +++ b/packages/runtime/src/execute/expression.ts @@ -66,14 +66,16 @@ export default ( duration = Date.now() - duration; + const finalState = prepareFinalState(opts, result); + notify(NOTIFY_JOB_COMPLETE, { duration, - state: result, + state: finalState, jobId: id, }); // return the final state - resolve(prepareFinalState(opts, result)); + resolve(finalState); } catch (e: any) { duration = Date.now() - duration; let finalError; From c448a237c1221a68546197b42cb80fb2dcc92f25 Mon Sep 17 00:00:00 2001 From: Joe Clark Date: Sun, 12 Nov 2023 14:40:53 +0000 Subject: [PATCH 2/2] changeset --- .changeset/nice-poets-attack.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nice-poets-attack.md diff --git a/.changeset/nice-poets-attack.md b/.changeset/nice-poets-attack.md new file mode 100644 index 000000000..e338d298c --- /dev/null +++ b/.changeset/nice-poets-attack.md @@ -0,0 +1,5 @@ +--- +'@openfn/runtime': patch +--- + +Fix an issue where expression result state is not serialized before being broadcast, causing blowups