Fix default machine preset in config not being used (#1321)

* Add additional error message and stack trace when a task file cannot be imported for run

* Apply default machine preset in config
This commit is contained in:
Eric Allam
2024-09-18 22:00:59 +01:00
committed by GitHub
parent d8006e15ac
commit 3b15224453
8 changed files with 36 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Apply default machine preset in config
+5
View File
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---
Add additional error message and stack trace when a task file cannot be imported for run
@@ -95,9 +95,25 @@ async function bootstrap() {
};
}
const { buildManifest, importErrors } = await bootstrap();
const { buildManifest, importErrors, config } = await bootstrap();
const tasks = taskCatalog.listTaskManifests();
let tasks = taskCatalog.listTaskManifests();
// If the config has a machine preset, we need to apply it to all tasks that don't have a machine preset
if (typeof config.machine === "string") {
tasks = tasks.map((task) => {
if (typeof task.machine?.preset !== "string") {
return {
...task,
machine: {
preset: config.machine,
},
};
}
return task;
});
}
await sendMessageInCatalog(
indexerToWorkerMessages,
@@ -219,6 +219,7 @@ const zodIpc = new ZodIpcConnection({
error: {
type: "INTERNAL_ERROR",
code: TaskRunErrorCodes.COULD_NOT_FIND_TASK,
message: `Could not find task ${execution.task.id}. Make sure the task is exported and the ID is correct.`,
},
usage: {
durationMs: 0,
@@ -248,6 +249,8 @@ const zodIpc = new ZodIpcConnection({
error: {
type: "INTERNAL_ERROR",
code: TaskRunErrorCodes.COULD_NOT_IMPORT_TASK,
message: err instanceof Error ? err.message : String(err),
stackTrace: err instanceof Error ? err.stack : undefined,
},
usage: {
durationMs: 0,
@@ -219,6 +219,8 @@ const zodIpc = new ZodIpcConnection({
error: {
type: "INTERNAL_ERROR",
code: TaskRunErrorCodes.COULD_NOT_IMPORT_TASK,
message: err instanceof Error ? err.message : String(err),
stackTrace: err instanceof Error ? err.stack : undefined,
},
usage: {
durationMs: 0,
@@ -49,6 +49,7 @@ export async function indexWorkerManifest({
OTEL_IMPORT_HOOK_EXCLUDES: otelHookExclude?.join(","),
TRIGGER_BUILD_MANIFEST_PATH: buildManifestPath,
NODE_OPTIONS: nodeOptions,
TRIGGER_INDEXING: "1",
},
execPath: execPathForRuntime(runtime),
});
@@ -11,6 +11,7 @@ let headerGenerator = new HeaderGenerator({
export const fetchPostTask = task({
id: "fetch-post-task",
machine: { preset: "small-1x" },
run: async (payload: { url: string }) => {
const headers = headerGenerator.getHeaders({
operatingSystems: ["linux"],
+1 -1
View File
@@ -13,7 +13,7 @@ export { handleError } from "./src/handleError.js";
export default defineConfig({
runtime: "node",
project: "yubjwjsfkxnylobaqvqz",
machine: "small-2x",
machine: "medium-1x",
instrumentations: [new OpenAIInstrumentation()],
additionalFiles: ["wrangler/wrangler.toml"],
retries: {