Get parent/root task metadata
Currently, there are plenty of methods to update the parent/root metadata of a task but no way to get the parent/root metadata.
Can’t we have something like metadata.parent() and metadata.root(), similarly to how we have metadata.current()?
Comments2
maverickdotdev
Jan 16, 2025
I’m curious as to the use case behind this request? I purposefully didn’t implement this because the parent metadata is “eventually consistent” and would be pretty tricky to implement well. You can manually pass the parent metadata to the child metadata:
https://trigger.dev/docs/runs/metadata#metadata-propagation
Dimitar Stoykov
Jan 16, 2025
I now realise that its probably a very niche use case but to answer your question:
In our project we already have pub-sub system (with Redis) that we use to publish events from inside of the tasks. We have a trigger.dev parent task that triggers N processing sub-tasks concurrently. We want to track the overall progress but since we don’t use trigger.dev’s realtime functionality, each sub-task needs to get the current (up-to-date) parent task metadata before it increments it and publishes it to the pub-sub.