OpenFn / kit

The bits & pieces that make OpenFn work. (diagrammer, cli, compiler, runtime, runtime manager, logger, etc.)
10 stars 9 forks source link

Compiler: warn when bare state chains are used #630

Open josephjclark opened 6 months ago

josephjclark commented 6 months ago

We teach users to pass state values into operations.

But state references can go stale (an issue made worse by global state, which I think should be removed, see #17) or not be assigned yet because they are read synchronously.

For example:

get('/some-data')
post('some-data', state.data)

This code will fail because the value of state.data is read synchronously, because the get was completed.

It should be written with some kind of lazy state evaluation, like this:

get('/some-data')
post('some-data, (state) => state.data)

The compiler should be able to detect references to state (literally that global variable reference) and raise a warning when it is used in a naive chain like this.