OpenFn / OpenFn/kit

State globals in the new runtime

Open
#17 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design DevX
Dominant language
TypeScript
Stars
21
Forks
23
Avg merge
1d 22h
Merged PRs (30d)
17

Description

In the v1 runtime, state is provided as a global object. So you can do stuff like this:

create({
   name: state.data.name
}});

Which is nice and good and simple.

But I'm going to suggest we remove the state global from the v2 runtime.

  • The new runtime has a stricter notion of immutable state. A cloned state object should be passed into each operation (it's an open question whether we allow mutation within the operation or if we force an immutable object).
  • This ensures the integrity of the state object in each operation, which is critical for reproducing bugs and reporting on what is happening within the job
  • But obviously with a global state object we can't do anything to preserve the integrity across operations.

This gives us a problem with legacy code which references global state. But it's easy to migrate!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, entry points, or tests. Start by locating the v2 runtime's state handling and references to the global state object, then determine how cloned state is passed to each operation and how legacy references migrate; done means v2 no longer relies on global state while operation state integrity is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.