Auto-yielding is skipped for tasks that are no-ops and subtasks
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@trigger.dev/sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Don't auto-yield with no-op tasks (e.g. logs) that are subtasks
|
||||||
@@ -214,12 +214,12 @@ export class IO {
|
|||||||
return new IOLogger(async (level, message, data) => {
|
return new IOLogger(async (level, message, data) => {
|
||||||
let logLevel: LogLevel = "info";
|
let logLevel: LogLevel = "info";
|
||||||
|
|
||||||
if(data instanceof Error){
|
if (data instanceof Error) {
|
||||||
data = {
|
data = {
|
||||||
name : data.name,
|
name: data.name,
|
||||||
message : data.message,
|
message: data.message,
|
||||||
stack : data.stack
|
stack: data.stack,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
|
if (Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
|
||||||
@@ -1097,8 +1097,6 @@ export class IO {
|
|||||||
options?: RunTaskOptions & { parseOutput?: (output: unknown) => T },
|
options?: RunTaskOptions & { parseOutput?: (output: unknown) => T },
|
||||||
onError?: RunTaskErrorCallback
|
onError?: RunTaskErrorCallback
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
this.#detectAutoYield("start_task", 500);
|
|
||||||
|
|
||||||
const parentId = this._taskStorage.getStore()?.taskId;
|
const parentId = this._taskStorage.getStore()?.taskId;
|
||||||
|
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
@@ -1109,6 +1107,12 @@ export class IO {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//don't auto-yield if it's a no-op and a subtask (e.g. a log inside a task)
|
||||||
|
const isSubtaskNoop = options?.noop === true && parentId !== undefined;
|
||||||
|
if (!isSubtaskNoop) {
|
||||||
|
this.#detectAutoYield("start_task", 500);
|
||||||
|
}
|
||||||
|
|
||||||
const idempotencyKey = await generateIdempotencyKey(
|
const idempotencyKey = await generateIdempotencyKey(
|
||||||
[this._id, parentId ?? "", cacheKey].flat()
|
[this._id, parentId ?? "", cacheKey].flat()
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user