From c89680d9f5ddef6d8aa437c866bf2f5740afc18f Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 22 Aug 2024 15:58:12 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20issue=20where=20import=20errors=20weren?= =?UTF-8?q?=E2=80=99t=20coming=20through?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli-v3/src/dev/devOutput.ts | 25 +++++++++---------- .../cli-v3/src/executions/taskRunProcess.ts | 6 ++--- .../src/indexing/indexWorkerManifest.ts | 2 +- packages/cli-v3/src/indexing/registerTasks.ts | 19 +++++++++----- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/packages/cli-v3/src/dev/devOutput.ts b/packages/cli-v3/src/dev/devOutput.ts index ae2ad5792..4ac0e444f 100644 --- a/packages/cli-v3/src/dev/devOutput.ts +++ b/packages/cli-v3/src/dev/devOutput.ts @@ -1,6 +1,12 @@ +import { formatDurationMilliseconds } from "@trigger.dev/core/v3"; import { ResolvedConfig } from "@trigger.dev/core/v3/build"; +import { + createTaskMetadataFailedErrorStack, + TaskIndexingImportError, + TaskMetadataParseError, +} from "@trigger.dev/core/v3/errors"; +import { TaskRunError, TaskRunErrorCodes } from "@trigger.dev/core/v3/schemas"; import { DevCommandOptions } from "../commands/dev.js"; -import { logger } from "../utilities/logger.js"; import { chalkError, chalkGrey, @@ -15,17 +21,7 @@ import { prettyPrintDate, } from "../utilities/cliOutput.js"; import { eventBus, EventBusEventArgs } from "../utilities/eventBus.js"; -import { - TaskMetadataFailedToParseData, - TaskRunError, - TaskRunErrorCodes, -} from "@trigger.dev/core/v3/schemas"; -import { formatDurationMilliseconds } from "@trigger.dev/core/v3"; -import { - createTaskMetadataFailedErrorStack, - TaskIndexingImportError, - TaskMetadataParseError, -} from "@trigger.dev/core/v3/errors"; +import { logger } from "../utilities/logger.js"; export type DevOutputOptions = { name: string | undefined; @@ -78,7 +74,10 @@ export function startDevOutput(options: DevOutputOptions) { ) => { if (error instanceof TaskIndexingImportError) { for (const importError of error.importErrors) { - prettyError(`Could not import ${importError.file}`, importError.stack); + prettyError( + `Could not import ${importError.file}`, + importError.stack ?? importError.message + ); } } else if (error instanceof TaskMetadataParseError) { const errorStack = createTaskMetadataFailedErrorStack({ diff --git a/packages/cli-v3/src/executions/taskRunProcess.ts b/packages/cli-v3/src/executions/taskRunProcess.ts index 3d1ba3a52..815ea1d75 100644 --- a/packages/cli-v3/src/executions/taskRunProcess.ts +++ b/packages/cli-v3/src/executions/taskRunProcess.ts @@ -113,10 +113,8 @@ export class TaskRunProcess { OTEL_IMPORT_HOOK_INCLUDES: workerManifest.otelImportHook?.include?.join(","), // TODO: this will probably need to use something different for bun (maybe --preload?) NODE_OPTIONS: workerManifest.loaderEntryPoint - ? `--import=${workerManifest.loaderEntryPoint} ${ - env.NODE_OPTIONS ?? env.NODE_OPTIONS ?? "" - }` - : env.NODE_OPTIONS ?? env.NODE_OPTIONS ?? "", + ? `--import=${workerManifest.loaderEntryPoint} ${env.NODE_OPTIONS ?? ""}` + : env.NODE_OPTIONS ?? "", }; logger.debug(`[${this.runId}] initializing task run process`, { diff --git a/packages/cli-v3/src/indexing/indexWorkerManifest.ts b/packages/cli-v3/src/indexing/indexWorkerManifest.ts index c8af3dac3..147e28746 100644 --- a/packages/cli-v3/src/indexing/indexWorkerManifest.ts +++ b/packages/cli-v3/src/indexing/indexWorkerManifest.ts @@ -49,7 +49,7 @@ export async function indexWorkerManifest({ OTEL_IMPORT_HOOK_INCLUDES: otelHookInclude?.join(","), OTEL_IMPORT_HOOK_EXCLUDES: otelHookExclude?.join(","), TRIGGER_BUILD_MANIFEST_PATH: buildManifestPath, - NODE_OPTIONS: nodeOptions ? `${nodeOptions} ${env.NODE_OPTIONS ?? ""}` : env.NODE_OPTIONS, + NODE_OPTIONS: nodeOptions ? `${env.NODE_OPTIONS ?? ""} ${nodeOptions}` : env.NODE_OPTIONS, }, execPath: execPathForRuntime(runtime), }); diff --git a/packages/cli-v3/src/indexing/registerTasks.ts b/packages/cli-v3/src/indexing/registerTasks.ts index 21fc48dc0..00f073c38 100644 --- a/packages/cli-v3/src/indexing/registerTasks.ts +++ b/packages/cli-v3/src/indexing/registerTasks.ts @@ -7,12 +7,19 @@ export async function registerTasks(buildManifest: BuildManifest): Promise