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
[TRI-950] io.runTask
return type of the callback has TypeScript error when it includes an unknown
type
#280
Comments
io.runTask
return type of the callback has TypeScript error when it includes an unknown
typeio.runTask
return type of the callback has TypeScript error when it includes an unknown
type
/bounty $75 |
|
/attempt #280 Options |
/attempt #280 Options |
@Akshay-Patel-dev is already attempting to complete #280 and claim the bounty. If you attempt to complete the same issue, there is a chance that @Akshay-Patel-dev will complete the issue first, and be awarded the bounty. Try discussing with @Akshay-Patel-dev and potentially collaborating on the same solution versus creating an alternate solution. |
Hello,@ericallam Can you explain a bit more |
I was able to reproduce the issue but it is not clear what needs to be done so far. It would be nice to get some details /attempt #280 Options |
how about we having a wrapper something like this
|
@yashug even thought this would work, it's not safety right? We would be getting a type safety at transpile/development, but on runtime the data type could be different and bring unexpected behaviors |
@Akshay-Patel-dev: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
@ericallam, can you take a look at #342? I decided to take a shot, and if you test with your example await io.runTask("foo", { name: "Foo" }, async () => {
return {
foo: "bar",
} as unknown;
}); It's working now |
Do you see a way of handling this without a breaking change? |
💡 @ologbonowiwi submitted a pull request that claims the bounty. You can visit your org dashboard to reward. |
@MeenuyD: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
@ologbonowiwi: Your claim has been rewarded! 👉 Complete your Algora onboarding to collect the bounty. |
🎉🎈 @ologbonowiwi has been awarded $75! 🎈🎊 |
Can we close this one guys? @ericallam @matt-aitken |
Can we close it, guys? @matt-aitken @ericallam |
Yep @ologbonowiwi, I'll close now |
To recreate this issue:
That is because the return type of the callback is typed as required to extend
SerializedJson
:trigger.dev/packages/trigger-sdk/src/io.ts
Line 434 in fa942fc
We do this so the types of the return of
runTask
will match what is actually returned, since we run the results of therunTask
callback through a JSON stringify/parsing as task output is stored in the database as JSON. Because of Resumability, this is a requirement, unless another solution can be identified.I'm also now realizing that this SerializedJson might be incorrectly typed as well, as it can include
Date
andSymbol
:trigger.dev/packages/core/src/schemas/json.ts
Line 12 in fa942fc
So this could cause issues when resuming a run and using the cached task output, where Date's would be symbols and the types would be wrong. It would be great to test this and possible change the required type to
DeserializedJson
.TRI-950
The text was updated successfully, but these errors were encountered: