@trigger.dev/core 3.0.0-beta.20 → 3.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{catalog-TAZd4-TP.d.ts → catalog-KJXg8k3W.d.ts} +25 -4
- package/dist/{catalog-A-D3UC6S.d.mts → catalog-PA64uhhi.d.mts} +25 -4
- package/dist/v3/index.d.mts +2 -2
- package/dist/v3/index.d.ts +2 -2
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +2 -2
- package/dist/v3/workers/index.d.ts +2 -2
- package/dist/v3/workers/index.js +120 -14
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +120 -14
- package/dist/v3/workers/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1969,11 +1969,18 @@ function accessoryAttributes(accessory) {
|
|
|
1969
1969
|
__name(accessoryAttributes, "accessoryAttributes");
|
|
1970
1970
|
|
|
1971
1971
|
// src/v3/workers/taskExecutor.ts
|
|
1972
|
-
var _callRun, callRun_fn,
|
|
1972
|
+
var _callRun, callRun_fn, _callInitFunctions, callInitFunctions_fn, _callConfigInit, callConfigInit_fn, _callOnSuccessFunctions, callOnSuccessFunctions_fn, _callOnSuccessFunction, callOnSuccessFunction_fn, _callOnFailureFunctions, callOnFailureFunctions_fn, _callOnFailureFunction, callOnFailureFunction_fn, _callOnStartFunctions, callOnStartFunctions_fn, _callOnStartFunction, callOnStartFunction_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
|
|
1973
1973
|
var _TaskExecutor = class _TaskExecutor {
|
|
1974
1974
|
constructor(task, options) {
|
|
1975
1975
|
__privateAdd(this, _callRun);
|
|
1976
|
-
__privateAdd(this,
|
|
1976
|
+
__privateAdd(this, _callInitFunctions);
|
|
1977
|
+
__privateAdd(this, _callConfigInit);
|
|
1978
|
+
__privateAdd(this, _callOnSuccessFunctions);
|
|
1979
|
+
__privateAdd(this, _callOnSuccessFunction);
|
|
1980
|
+
__privateAdd(this, _callOnFailureFunctions);
|
|
1981
|
+
__privateAdd(this, _callOnFailureFunction);
|
|
1982
|
+
__privateAdd(this, _callOnStartFunctions);
|
|
1983
|
+
__privateAdd(this, _callOnStartFunction);
|
|
1977
1984
|
__privateAdd(this, _callTaskCleanup);
|
|
1978
1985
|
__privateAdd(this, _handleError);
|
|
1979
1986
|
this.task = task;
|
|
@@ -2007,8 +2014,12 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2007
2014
|
try {
|
|
2008
2015
|
const payloadPacket = await conditionallyImportPacket(originalPacket, this._tracer);
|
|
2009
2016
|
parsedPayload = await parsePacket(payloadPacket);
|
|
2010
|
-
|
|
2017
|
+
if (execution.attempt.number === 1) {
|
|
2018
|
+
await __privateMethod(this, _callOnStartFunctions, callOnStartFunctions_fn).call(this, parsedPayload, ctx);
|
|
2019
|
+
}
|
|
2020
|
+
initOutput = await __privateMethod(this, _callInitFunctions, callInitFunctions_fn).call(this, parsedPayload, ctx);
|
|
2011
2021
|
const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, initOutput);
|
|
2022
|
+
await __privateMethod(this, _callOnSuccessFunctions, callOnSuccessFunctions_fn).call(this, parsedPayload, output, ctx, initOutput);
|
|
2012
2023
|
try {
|
|
2013
2024
|
const stringifiedOutput = await stringifyIO(output);
|
|
2014
2025
|
const finalOutput = await conditionallyExportPacket(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
|
|
@@ -2038,6 +2049,9 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2038
2049
|
try {
|
|
2039
2050
|
const handleErrorResult = await __privateMethod(this, _handleError, handleError_fn).call(this, execution, runError, parsedPayload, ctx);
|
|
2040
2051
|
recordSpanException(span, handleErrorResult.error ?? runError);
|
|
2052
|
+
if (handleErrorResult.status !== "retry") {
|
|
2053
|
+
await __privateMethod(this, _callOnFailureFunctions, callOnFailureFunctions_fn).call(this, parsedPayload, handleErrorResult.error ?? runError, ctx, initOutput);
|
|
2054
|
+
}
|
|
2041
2055
|
return {
|
|
2042
2056
|
id: execution.run.id,
|
|
2043
2057
|
ok: false,
|
|
@@ -2101,8 +2115,9 @@ callRun_fn = /* @__PURE__ */ __name(async function(payload, ctx, init) {
|
|
|
2101
2115
|
})
|
|
2102
2116
|
});
|
|
2103
2117
|
}, "#callRun");
|
|
2104
|
-
|
|
2105
|
-
|
|
2118
|
+
_callInitFunctions = new WeakSet();
|
|
2119
|
+
callInitFunctions_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
2120
|
+
await __privateMethod(this, _callConfigInit, callConfigInit_fn).call(this, payload1, ctx1);
|
|
2106
2121
|
const initFn = this.task.fns.init;
|
|
2107
2122
|
if (!initFn) {
|
|
2108
2123
|
return {};
|
|
@@ -2111,23 +2126,114 @@ callTaskInit_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
|
2111
2126
|
return await initFn(payload1, {
|
|
2112
2127
|
ctx: ctx1
|
|
2113
2128
|
});
|
|
2129
|
+
}, {
|
|
2130
|
+
attributes: {
|
|
2131
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2132
|
+
}
|
|
2133
|
+
});
|
|
2134
|
+
}, "#callInitFunctions");
|
|
2135
|
+
_callConfigInit = new WeakSet();
|
|
2136
|
+
callConfigInit_fn = /* @__PURE__ */ __name(async function(payload2, ctx2) {
|
|
2137
|
+
const initFn = this._importedConfig?.init;
|
|
2138
|
+
if (!initFn) {
|
|
2139
|
+
return {};
|
|
2140
|
+
}
|
|
2141
|
+
return this._tracer.startActiveSpan("config.init", async (span) => {
|
|
2142
|
+
return await initFn(payload2, {
|
|
2143
|
+
ctx: ctx2
|
|
2144
|
+
});
|
|
2145
|
+
}, {
|
|
2146
|
+
attributes: {
|
|
2147
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2148
|
+
}
|
|
2114
2149
|
});
|
|
2115
|
-
}, "#
|
|
2150
|
+
}, "#callConfigInit");
|
|
2151
|
+
_callOnSuccessFunctions = new WeakSet();
|
|
2152
|
+
callOnSuccessFunctions_fn = /* @__PURE__ */ __name(async function(payload3, output, ctx3, initOutput) {
|
|
2153
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this.task.fns.onSuccess, "task.onSuccess", payload3, output, ctx3, initOutput);
|
|
2154
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this._importedConfig?.onSuccess, "config.onSuccess", payload3, output, ctx3, initOutput);
|
|
2155
|
+
}, "#callOnSuccessFunctions");
|
|
2156
|
+
_callOnSuccessFunction = new WeakSet();
|
|
2157
|
+
callOnSuccessFunction_fn = /* @__PURE__ */ __name(async function(onSuccessFn, name, payload4, output1, ctx4, initOutput1) {
|
|
2158
|
+
if (!onSuccessFn) {
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
try {
|
|
2162
|
+
await this._tracer.startActiveSpan(name, async (span) => {
|
|
2163
|
+
return await onSuccessFn(payload4, output1, {
|
|
2164
|
+
ctx: ctx4,
|
|
2165
|
+
init: initOutput1
|
|
2166
|
+
});
|
|
2167
|
+
}, {
|
|
2168
|
+
attributes: {
|
|
2169
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
} catch {
|
|
2173
|
+
}
|
|
2174
|
+
}, "#callOnSuccessFunction");
|
|
2175
|
+
_callOnFailureFunctions = new WeakSet();
|
|
2176
|
+
callOnFailureFunctions_fn = /* @__PURE__ */ __name(async function(payload5, error, ctx5, initOutput2) {
|
|
2177
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this.task.fns.onFailure, "task.onFailure", payload5, error, ctx5, initOutput2);
|
|
2178
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this._importedConfig?.onFailure, "config.onFailure", payload5, error, ctx5, initOutput2);
|
|
2179
|
+
}, "#callOnFailureFunctions");
|
|
2180
|
+
_callOnFailureFunction = new WeakSet();
|
|
2181
|
+
callOnFailureFunction_fn = /* @__PURE__ */ __name(async function(onFailureFn, name1, payload6, error1, ctx6, initOutput3) {
|
|
2182
|
+
if (!onFailureFn) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
try {
|
|
2186
|
+
return await this._tracer.startActiveSpan(name1, async (span) => {
|
|
2187
|
+
return await onFailureFn(payload6, error1, {
|
|
2188
|
+
ctx: ctx6,
|
|
2189
|
+
init: initOutput3
|
|
2190
|
+
});
|
|
2191
|
+
}, {
|
|
2192
|
+
attributes: {
|
|
2193
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
} catch (e) {
|
|
2197
|
+
}
|
|
2198
|
+
}, "#callOnFailureFunction");
|
|
2199
|
+
_callOnStartFunctions = new WeakSet();
|
|
2200
|
+
callOnStartFunctions_fn = /* @__PURE__ */ __name(async function(payload7, ctx7) {
|
|
2201
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this._importedConfig?.onStart, "config.onStart", payload7, ctx7, {});
|
|
2202
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this.task.fns.onStart, "task.onStart", payload7, ctx7, {});
|
|
2203
|
+
}, "#callOnStartFunctions");
|
|
2204
|
+
_callOnStartFunction = new WeakSet();
|
|
2205
|
+
callOnStartFunction_fn = /* @__PURE__ */ __name(async function(onStartFn, name2, payload8, ctx8, initOutput4) {
|
|
2206
|
+
if (!onStartFn) {
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
try {
|
|
2210
|
+
await this._tracer.startActiveSpan(name2, async (span) => {
|
|
2211
|
+
return await onStartFn(payload8, {
|
|
2212
|
+
ctx: ctx8
|
|
2213
|
+
});
|
|
2214
|
+
}, {
|
|
2215
|
+
attributes: {
|
|
2216
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2217
|
+
}
|
|
2218
|
+
});
|
|
2219
|
+
} catch {
|
|
2220
|
+
}
|
|
2221
|
+
}, "#callOnStartFunction");
|
|
2116
2222
|
_callTaskCleanup = new WeakSet();
|
|
2117
|
-
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(
|
|
2223
|
+
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(payload9, ctx9, init1) {
|
|
2118
2224
|
const cleanupFn = this.task.fns.cleanup;
|
|
2119
2225
|
if (!cleanupFn) {
|
|
2120
2226
|
return;
|
|
2121
2227
|
}
|
|
2122
2228
|
return this._tracer.startActiveSpan("cleanup", async (span) => {
|
|
2123
|
-
return await cleanupFn(
|
|
2124
|
-
ctx:
|
|
2229
|
+
return await cleanupFn(payload9, {
|
|
2230
|
+
ctx: ctx9,
|
|
2125
2231
|
init: init1
|
|
2126
2232
|
});
|
|
2127
2233
|
});
|
|
2128
2234
|
}, "#callTaskCleanup");
|
|
2129
2235
|
_handleError = new WeakSet();
|
|
2130
|
-
handleError_fn = /* @__PURE__ */ __name(async function(execution,
|
|
2236
|
+
handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payload10, ctx10) {
|
|
2131
2237
|
const retriesConfig = this._importedConfig?.retries ?? this._config.retries;
|
|
2132
2238
|
const retry = this.task.retry ?? retriesConfig?.default;
|
|
2133
2239
|
if (!retry) {
|
|
@@ -2142,13 +2248,13 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error, payload
|
|
|
2142
2248
|
};
|
|
2143
2249
|
}
|
|
2144
2250
|
return this._tracer.startActiveSpan("handleError()", async (span) => {
|
|
2145
|
-
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(
|
|
2146
|
-
ctx:
|
|
2251
|
+
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(payload10, error2, {
|
|
2252
|
+
ctx: ctx10,
|
|
2147
2253
|
retry,
|
|
2148
2254
|
retryDelayInMs: delay,
|
|
2149
2255
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|
|
2150
|
-
}) : this._importedConfig ? await this._handleErrorFn?.(
|
|
2151
|
-
ctx:
|
|
2256
|
+
}) : this._importedConfig ? await this._handleErrorFn?.(payload10, error2, {
|
|
2257
|
+
ctx: ctx10,
|
|
2152
2258
|
retry,
|
|
2153
2259
|
retryDelayInMs: delay,
|
|
2154
2260
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|