-
Notifications
You must be signed in to change notification settings - Fork 9
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
Methods on objects returned from ctx.run are missing in 1.4.0 #454
Comments
1.4.0 fixes a determinism issue, where previously you were receiving the exact value/reference returned by your inner run function, however the serialised-then-deserialised value which would be provided on replays could be different, therefore they now serialise the value first, then provide the user with the deserialised value, to ensure determinism across replays Your ctx.run usage does not define a custom Serde, so it will be using the built-in JSON Serde, which does do a JSON.stringify and JSON.parse You probably already had an issue on 1.3 with your code if you were to have any replays, it would fail on the same line because the deserialised value would also not have methods, you could test that now More info: https://docs.restate.dev/develop/ts/serialization |
@mupperton is indeed right, by default what you return from Perhaps this needs a sentence or two in the docs to clarify it. |
If you want to do this you can use https://deepkit.io/library/type for serialization and deserialization. |
Ah okay, I guess I'll have to do some refactors then to fix that issue. Thanks for the clarification! |
Actually one more thing: would it be possible to update the return type of This way you could enforce correct handling of the result through the type system.
Something like this: microsoft/TypeScript#48697 |
Hey there,
I recently upgraded my restate-sdk from 1.3.1 to 1.4.0 and started getting a bunch of errors related to missing methods.
For example, I have a call like:
and it fails with
object.save is undefined
. I debugged the code andobject
is defined, but the methods are missing on it. I get errors like this on a bunch of areas in my codebase that return class objects.This just started happening after the upgrade from 1.3.1 to 1.4.0. Not sure if context.run is JSON-ifying the object and removing methods on the return result. I had to downgrade back to 1.3.1 to fix it.
The text was updated successfully, but these errors were encountered: