[TRI-1449] Display warning message when duplicate job IDs are detected (#699)
* add warning message when duplicate job IDs are detected * fix warning message for duplicated job IDs in defineJob * Create bright-buckets-bow.md --------- Co-authored-by: Eric Allam <eric@trigger.dev>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/sdk": patch
|
||||
---
|
||||
|
||||
[TRI-1449] Display warning message when duplicate job IDs are detected
|
||||
@@ -28,6 +28,7 @@
|
||||
"@trigger.dev/core": "workspace:^2.2.4",
|
||||
"@trigger.dev/core-backend": "workspace:^2.2.4",
|
||||
"chalk": "^5.2.0",
|
||||
"colorette": "^2.0.20",
|
||||
"cronstrue": "^2.21.0",
|
||||
"debug": "^4.3.4",
|
||||
"evt": "^2.4.13",
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
SourceMetadataV2,
|
||||
StatusUpdate,
|
||||
} from "@trigger.dev/core";
|
||||
import { yellow } from "colorette";
|
||||
import { ApiClient } from "./apiClient";
|
||||
import {
|
||||
AutoYieldExecutionError,
|
||||
@@ -480,6 +481,15 @@ export class TriggerClient {
|
||||
TIntegrations extends Record<string, TriggerIntegration> = {},
|
||||
TOutput extends any = any,
|
||||
>(options: JobOptions<TTrigger, TIntegrations, TOutput>) {
|
||||
|
||||
const existingRegisteredJob = this.#registeredJobs[options.id];
|
||||
|
||||
if (existingRegisteredJob) {
|
||||
console.warn(
|
||||
yellow(`[@trigger.dev/sdk] Warning: The Job "${existingRegisteredJob.id}" you're attempting to define has already been defined. Please assign a different ID to the job.`)
|
||||
);
|
||||
}
|
||||
|
||||
return new Job<TTrigger, TIntegrations, TOutput>(this, options);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user