Skip to content

Commit 3b15224

Browse files
authored
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
1 parent d8006e1 commit 3b15224

File tree

8 files changed

+36
-3
lines changed

8 files changed

+36
-3
lines changed

.changeset/new-yaks-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Apply default machine preset in config

.changeset/quick-bulldogs-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Add additional error message and stack trace when a task file cannot be imported for run

packages/cli-v3/src/entryPoints/deploy-index-worker.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,25 @@ async function bootstrap() {
9595
};
9696
}
9797

98-
const { buildManifest, importErrors } = await bootstrap();
98+
const { buildManifest, importErrors, config } = await bootstrap();
99+
100+
let tasks = taskCatalog.listTaskManifests();
101+
102+
// If the config has a machine preset, we need to apply it to all tasks that don't have a machine preset
103+
if (typeof config.machine === "string") {
104+
tasks = tasks.map((task) => {
105+
if (typeof task.machine?.preset !== "string") {
106+
return {
107+
...task,
108+
machine: {
109+
preset: config.machine,
110+
},
111+
};
112+
}
99113

100-
const tasks = taskCatalog.listTaskManifests();
114+
return task;
115+
});
116+
}
101117

102118
await sendMessageInCatalog(
103119
indexerToWorkerMessages,

packages/cli-v3/src/entryPoints/deploy-run-worker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ const zodIpc = new ZodIpcConnection({
219219
error: {
220220
type: "INTERNAL_ERROR",
221221
code: TaskRunErrorCodes.COULD_NOT_FIND_TASK,
222+
message: `Could not find task ${execution.task.id}. Make sure the task is exported and the ID is correct.`,
222223
},
223224
usage: {
224225
durationMs: 0,
@@ -248,6 +249,8 @@ const zodIpc = new ZodIpcConnection({
248249
error: {
249250
type: "INTERNAL_ERROR",
250251
code: TaskRunErrorCodes.COULD_NOT_IMPORT_TASK,
252+
message: err instanceof Error ? err.message : String(err),
253+
stackTrace: err instanceof Error ? err.stack : undefined,
251254
},
252255
usage: {
253256
durationMs: 0,

packages/cli-v3/src/entryPoints/dev-run-worker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ const zodIpc = new ZodIpcConnection({
219219
error: {
220220
type: "INTERNAL_ERROR",
221221
code: TaskRunErrorCodes.COULD_NOT_IMPORT_TASK,
222+
message: err instanceof Error ? err.message : String(err),
223+
stackTrace: err instanceof Error ? err.stack : undefined,
222224
},
223225
usage: {
224226
durationMs: 0,

packages/cli-v3/src/indexing/indexWorkerManifest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export async function indexWorkerManifest({
4949
OTEL_IMPORT_HOOK_EXCLUDES: otelHookExclude?.join(","),
5050
TRIGGER_BUILD_MANIFEST_PATH: buildManifestPath,
5151
NODE_OPTIONS: nodeOptions,
52+
TRIGGER_INDEXING: "1",
5253
},
5354
execPath: execPathForRuntime(runtime),
5455
});

references/v3-catalog/src/trigger/simple.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ let headerGenerator = new HeaderGenerator({
1111

1212
export const fetchPostTask = task({
1313
id: "fetch-post-task",
14+
machine: { preset: "small-1x" },
1415
run: async (payload: { url: string }) => {
1516
const headers = headerGenerator.getHeaders({
1617
operatingSystems: ["linux"],

references/v3-catalog/trigger.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export { handleError } from "./src/handleError.js";
1313
export default defineConfig({
1414
runtime: "node",
1515
project: "yubjwjsfkxnylobaqvqz",
16-
machine: "small-2x",
16+
machine: "medium-1x",
1717
instrumentations: [new OpenAIInstrumentation()],
1818
additionalFiles: ["wrangler/wrangler.toml"],
1919
retries: {

0 commit comments

Comments
 (0)