Worker: ensure that final_state gets redacted - #1518
Merged
Conversation
doc-han
self-requested a review
August 31, 2026 12:00
doc-han
approved these changes
Aug 31, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns out there's a long-standing bug where large dataclips moving between the inner engine child process and the main worker thread are NOT properly redacted.
I don't know how or why, or how I didn;t notice, but it seems we only redact state.data and ignore other keys. This is crazy.
So what's happening right now in production is:
{ step1: { data }, step2: { data }, rather than just{ data }I think we sort of escaped this because the engine notes that the state is redacted, and then the worker refusses to send it back to lightning. So it sort of works itself out.
But the run-complete event does not do this. So
final_statewas being sent unredacted through the websocket. Any final state object bigger than 11mb causes lightning's cowboy to drop the frame and disconnect the worker, resulting in the whole run getting lost.These multi-leaf cron jobs have a tendency to bloat state over time. And now we're seeing some of these large objects causing real problems.
Fixes #1517
There are two fixes here:
QA Notes
This is easily reproduced.
Check out this workflow on staging: https://app.staging.openfn.org/projects/b387f5a4-a3bb-4bb8-8093-f99436d09d92/w/ace8117e-dcfa-481f-b341-ea06978c366d?step=05155006-7d8c-462e-b215-449f52c450b2#log
It has two leaf nodes which both return an object of, uh 7mb (6 mb should do it but it doesn't seem to trigger, eh whatever).
Each output dataclip is small enough that it gets returned to the app (see the output for each step and you;ll find the state objects). But large enough that when they're both aggregated into a single final_state, they blow the cowboy limit and the run will be lost.
This workflow runs great locally with this fix in place.
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy