-
-
Notifications
You must be signed in to change notification settings - Fork 940
Closed
Labels
area/integrationsarea/serverIssues related to the Trigger.dev serverIssues related to the Trigger.dev serverenhancementNew feature or requestNew feature or request
Milestone
Description
What is it?
Sometimes you only want a Task to run once across your entire Project/Job.
One example is sending non-recurring emails. This should only ever happen exactly once.
await io.resend.sendEmail("welcome-email", {
to: user.email,
subject: "Welcome to Trigger.dev!",
react: <WelcomeEmail user={user} />,
from: "Trigger.dev <hello@email.trigger.dev>",
}, {
deduplicationKey: `welcome-email-${user.id}`,
//optional and defaults to "project", but can be "job" or "organization" as well
deduplicationScope: "project"
});
It would be impossible to have another Task run with the same deduplicationKey inside a project in this case.
If you specified the scope to be "job" or "organization" it would deduplicate at that scope instead.
If it has already run a Task with the same dedupe key it would return the data, just like the key does.
Implementation
- Add a deduplicationKey column to the Task table which is a unique String, required, and defaults to a
cuid. Migration needs to add unique ids to all existing Tasks. - Add SDK support to runTask
- On the server it would prepend the
proj:${projectId},org:${orgId},job:${jobId}to the key before it's saved to the database. Also on lookup it needs to do the same. - Roll out support to integrations
From SyncLinear.com | TRI-1132
louisthomaspro
Metadata
Metadata
Assignees
Labels
area/integrationsarea/serverIssues related to the Trigger.dev serverIssues related to the Trigger.dev serverenhancementNew feature or requestNew feature or request