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) => {
|
||||
let logLevel: LogLevel = "info";
|
||||
|
||||
if(data instanceof Error){
|
||||
if (data instanceof Error) {
|
||||
data = {
|
||||
name : data.name,
|
||||
message : data.message,
|
||||
stack : data.stack
|
||||
}
|
||||
name: data.name,
|
||||
message: data.message,
|
||||
stack: data.stack,
|
||||
};
|
||||
}
|
||||
|
||||
if (Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
|
||||
@@ -1097,8 +1097,6 @@ export class IO {
|
||||
options?: RunTaskOptions & { parseOutput?: (output: unknown) => T },
|
||||
onError?: RunTaskErrorCallback
|
||||
): Promise<T> {
|
||||
this.#detectAutoYield("start_task", 500);
|
||||
|
||||
const parentId = this._taskStorage.getStore()?.taskId;
|
||||
|
||||
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(
|
||||
[this._id, parentId ?? "", cacheKey].flat()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user