Are .runAfter(0, api.something) awaited ?
Hi, I'm using R2 components to store files with an Action. I'm running into an issue where the r2.getUrl() is returning an url before r2.store() or Cloudflare R2 finish processing my file to their CDN. Adding a 1 second promise between getting the url and displaying the url fixes it but it's very ugly. Any suggestions ?
2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
While the docs do show the
.runAfter
method being called using await
, that just waits for the scheduling of the target function to complete, not the execution of that scheduled function (even with a delay of zero).
My suggestion would be to have that scheduled function update the appropriate document to save the R2 URL once it's been returned. The UI component can look for the presence of that URL, and because of the reactive nature of the query, the URL will be available for the UI to display once the query updates after the scheduled function is done.