//this is the job we want to cancel runs forclient.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);
Instance methods
TriggerClient: cancelRunsForJob() Instance Method
The cancelRunsForJob() instance method will cancel all job runs (yet to be executed) with the given jobId.
List of Job Run IDs that have failed to be cancelled.
//this is the job we want to cancel runs forclient.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);