-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQUEST] Better serialization in workflows #197
Comments
Hi there, defining a method for serialization is possible at serve level, but not possible in step level like you said. We can consider having serialize/deserialize methods at step level. If we add them, they can look wrong in Upstash Console, but it could still be more convenient to have these methods. We will make sure to check how this change affects console when we set about to implement it. Thanks a lot for the suggestion! |
Hi @aldebout , |
@sancar I reached out on discord :) |
Hi Alex, thanks for details. I think I have found how this is possible. Indeed we have a bug. To give more detail, SDK sends your As a solution, I think we shouldn't deserialize it at all , we should put it as is. We will fix this and update here as soon as the fix is deployed. |
It'd be really nice to be able to add a custom serializer/deserializer to workflow steps when passing data between them, especially since the type inference is currently happy with
Dates
and others even though it actually breaks in real life.Example:
Currently, this code (minus the serialize/deserialize bit) works typescript-wise, but fails in real life because
event.startDate
is not deserialized as aDate
but as astring
. I'm assuming the underlying logic is performing aJSON.stringify
/JSON.parse
.This could also be added at the
serve
level, to ensure consistency between the steps.I've tried doing it in userland, it works but is pretty annoying type-wise. I have not found a better way than explicitly defining all my return types and do
return devalue.stringify(response as ResponseType)
and thenconst parsedData = devalue.parse(data) as ResponseType
which is difficult when the return types are complex.One outstanding question: what does this mean for the actual qstash platform? Currently, you can see the output data on teh platform as what looks like a Go print, which sounds to me like the output is parsed by qstash and that would make the use of user-defined serialization hard to work with.
The text was updated successfully, but these errors were encountered: