Continutations: what exactly can be put in there?

I am looking to make use of the continuation functionality of Sync Tables, and understand how data returned gets handled. I want to know whether closures returned as part of the object can be accessed properly at the next invocation (implying the pack runtime is preserved between invocations).

The docs indicate:

The continuation will be passed verbatim as an input to the subsequent invocation of the sync formula.

I am not sure whether this is sentence should be taken literally to mean the exact same runtime object will be handed over to the next invocation, or just a representation of it (serialized and deserialized).

I suspect the latter, but wanted to confirm before implementing. Also, maybe the docs wording can be adjusted, since the way the object is serialized should be mentioned IMO.

@Eric_Koleda to the rescue for the accurate answer. But if I remember correctly myself, we had this conversation on our internal chat, and the consensus was: it’s only safe to put JSON’able stuff in there, such as literal strings, numbers etc, as well as arrays or objects of those but not functions, closures, symbols etc.

That’s logical too. If I understand it right, pack functions run on AWS lambdas. There is no guarantee that the same instance will be handling the subsequent request to your sync formula. Actually it’s probably almost certain that all the context would be lost, since pack invocations are additionally sandboxed with isolated-vm.

Wondering what Eric would say.

I see, thanks for the answer.

From the docs I later found in a different guide:

The continuation must be an object of type Continuation, which allows for storing string and number values.

I will confirm empirically what exactly happens to other data types returned, but seems to point towards some form of serialization.

That’s correct, we serialize the value to pass between executions, and we only allow strings and numbers. Passing a closure won’t work, unless you can find some way to serialize it to a string that preserves state.

1 Like

I think I did put plain objects and lists there though… nothing fancier than numbers and strings at the deepest but a little bit more structured IIRC

I do too and it works.