Instance methods
TriggerClient: cancelRunsForJob() Instance Method
Getting Started
Concepts
Guides
- Frameworks
- Using the CLI
- Manual setup
- Running your Jobs
- Managing Jobs
- Using the Dashboard
- Using Integrations
- React hooks
- Deployment
- Event Filters
- Zod
- Self hosting
- Contributing
Overview
- Introduction
- Create an Integration
Integrations
SDK
HTTP Reference
Overview
Instance methods
TriggerClient: cancelRunsForJob() Instance Method
The cancelRunsForJob()
instance method will cancel all job runs (yet to be executed) with the given jobId.
//this is the job we want to cancel runs for
client.defineJob({
//this is the job id
id: "my-job",
name: "My first job",
version: "1.0.0",
trigger: invokeTrigger({ schema: z.number() }),
run: async (payload, io, ctx) => {
await io.logger.info(`Hello World ${payload}`);
},
});
// Some time later...
const res = await client.cancelRunsForJob("my-job");
console.log(res.cancelledRunIds);
console.log(res.failedToCancelRunIds);
These are the docs for Trigger.dev v2 which will be deprecated on January 31st, 2025. You probably want the v3 docs.
Parameters
The job ID to cancel the job runs for. This is the id
you set when using client.defineJob()
or
new Job()
.
Returns
//this is the job we want to cancel runs for
client.defineJob({
//this is the job id
id: "my-job",
name: "My first job",
version: "1.0.0",
trigger: invokeTrigger({ schema: z.number() }),
run: async (payload, io, ctx) => {
await io.logger.info(`Hello World ${payload}`);
},
});
// Some time later...
const res = await client.cancelRunsForJob("my-job");
console.log(res.cancelledRunIds);
console.log(res.failedToCancelRunIds);
Was this page helpful?
//this is the job we want to cancel runs for
client.defineJob({
//this is the job id
id: "my-job",
name: "My first job",
version: "1.0.0",
trigger: invokeTrigger({ schema: z.number() }),
run: async (payload, io, ctx) => {
await io.logger.info(`Hello World ${payload}`);
},
});
// Some time later...
const res = await client.cancelRunsForJob("my-job");
console.log(res.cancelledRunIds);
console.log(res.failedToCancelRunIds);