Skip to content

Fix default machine preset in config not being used #1321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-yaks-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Apply default machine preset in config
5 changes: 5 additions & 0 deletions .changeset/quick-bulldogs-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Add additional error message and stack trace when a task file cannot be imported for run
20 changes: 18 additions & 2 deletions packages/cli-v3/src/entryPoints/deploy-index-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,25 @@ async function bootstrap() {
};
}

const { buildManifest, importErrors } = await bootstrap();
const { buildManifest, importErrors, config } = await bootstrap();

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,
},
};
}

const tasks = taskCatalog.listTaskManifests();
return task;
});
}

await sendMessageInCatalog(
indexerToWorkerMessages,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli-v3/src/entryPoints/deploy-run-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-v3/src/entryPoints/dev-run-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/cli-v3/src/indexing/indexWorkerManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down
1 change: 1 addition & 0 deletions references/v3-catalog/src/trigger/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion references/v3-catalog/trigger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading