Does the function runtime stay alive while the event loop is still active? (background promises)
I'm looking at ways to get my logs out to our existing observability platform (loki-compatible api). I think the best way to do this is to have my logger async upload logs to the sink, will the function keep running after I return a response? (query, action, mutation), or will the environment be immediately shut down once the function returns?
4 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!
A really hacky solution would be to have the logger call a
.runAt
to background schedule a function just for shipping logsnvm just found https://docs.convex.dev/production/integrations/log-streams/ idk how i didnt find it before lol
Log Streams | Convex Developer Hub
Configure logging integrations for your Convex deployment
Yeah log streaming integration is the way. But if you do use a service that doesn't have an integration,
runAt()
is the correct approach, nothing hacky about it. Especially because sending logs means using fetch, so it has to happen in a separate function for queries and mutaitons anyway.