Skip to content

Conversation

@josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Jan 7, 2026

Short Description

Adds a test to the runtime which measures the size of state objects before writing them to state. If they're too big, it'll throw an error.

Fixes #1203

Implementation Details

One big concern here: if the serializer fails to stringify, it seems to throw an uncatchable error, which WILL result in the run being lost. You can reproduce this by commenting out the Promise handling in the replacer. The test just times out. I am unable to trap this error anywhere.

QA Notes

List any considerations/cases/advice for testing/QA here.

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

@github-project-automation github-project-automation bot moved this to New Issues in v2 Jan 7, 2026
@josephjclark
Copy link
Collaborator Author

Handling the options here is a nightmare. I'l gonna remove the default one from the runtime - it doesn't make any damn sense, jim

I don't think this is the right option in the right place - I'll check into that later
@josephjclark
Copy link
Collaborator Author

Ok so this new limit should be working in the engine and runtime, with tests and a not totally insane API

Tomorrow I gotta tidy up the worker and get that configured correctly. Don't want to invest much in the API but I do want to be sure it's working

@josephjclark
Copy link
Collaborator Author

josephjclark commented Jan 7, 2026

Ok, I've fixed the size to either double the dataclip limit or 25% of the available memory limit, whichever is bigger. That should give everyone enough to play with.

I have not exposed these as options for now, because there's a lot of ceremony associated with that. I may do it in the morning.

I'm also a little unhappy that this limit isn't logged anywhere. I don't want to put it in the run log with the timeout etc. Maybe I'll log it to GCP.

profilePollInteval: context.options.profilePollInterval,
// work out the max size of the state object at the end of each step
// This must be fairly high to prevent crashes
stateLimitMb:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently set in the engine and worker with different rules!

Maybe the worker just passes in a fixed value, if it has one, and the engine defaults to a % of runtime memory. That's probably cleanest.

@josephjclark josephjclark marked this pull request as ready for review January 8, 2026 11:03
@josephjclark josephjclark changed the base branch from main to release/next January 8, 2026 12:01
@josephjclark josephjclark merged commit 064933d into release/next Jan 8, 2026
6 checks passed
@josephjclark josephjclark deleted the state-limit branch January 8, 2026 12:05
@github-project-automation github-project-automation bot moved this from New Issues to Done in v2 Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Runtime: stream serialization of state at the end of each step

2 participants