Fixed issue where import errors weren’t coming through
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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`, {
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
|
||||
@@ -7,12 +7,19 @@ export async function registerTasks(buildManifest: BuildManifest): Promise<Impor
|
||||
const [error, module] = await tryImport(file.out);
|
||||
|
||||
if (error) {
|
||||
importErrors.push({
|
||||
file: file.entry,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name,
|
||||
});
|
||||
if (typeof error === "string") {
|
||||
importErrors.push({
|
||||
file: file.entry,
|
||||
message: error,
|
||||
});
|
||||
} else {
|
||||
importErrors.push({
|
||||
file: file.entry,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name,
|
||||
});
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user