[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:
Alexandre Costa
2023-11-03 08:10:26 -03:00
committed by GitHub
parent cf8f994604
commit 7e57f1f3dd
3 changed files with 16 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---
[TRI-1449] Display warning message when duplicate job IDs are detected
+1
View File
@@ -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",
+10
View File
@@ -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);
}