Usage
Add metadata to a run by passing it as an object to thetrigger function:
metadata.get() or metadata.current() (again, only inside a run):
metadata.set(), metadata.save(), or metadata.del():
Calling
metadata.current() or metadata.get() outside of the run function will always return
undefined.trigger.config.ts file.
Metadata propagation
Metadata is NOT propagated to child tasks. If you want to pass metadata to a child task, you must do so explicitly:Type-safe metadata
The metadata APIs are currently loosely typed, accepting any object that is JSON-serializable:If you pass in an object like a Date, it will be serialized to a string when stored in the
metadata. That also means that when you retrieve it using
metadata.get() or
metadata.current(), you will get a string back. You will need to deserialize it back to a Date
object if you need to use it as a Date.Inspecting metadata
Dashboard
You can view the metadata for a run in the Trigger.dev dashboard. The metadata will be displayed in the run details view:
API
You can use theruns.retrieve() SDK function to get the metadata for a run:
Size limit
The maximum size of the metadata object is 4KB. If you exceed this limit, the SDK will throw an error. If you are self-hosting Trigger.dev, you can increase this limit by setting theTASK_RUN_METADATA_MAXIMUM_SIZE environment variable. For example, to increase the limit to 16KB, you would set TASK_RUN_METADATA_MAXIMUM_SIZE=16384.
