@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
|
@@ -4,8 +4,8 @@ export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.mj
|
|
|
4
4
|
import { p as TaskRunExecution, T as TaskRunExecutionResult } from '../../manager-M9GLDnhJ.mjs';
|
|
5
5
|
export { R as RuntimeManager } from '../../manager-M9GLDnhJ.mjs';
|
|
6
6
|
import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../messages-AriaDDm0.mjs';
|
|
7
|
-
import { d as TriggerTracer, g as Config,
|
|
8
|
-
export { O as OtelTaskLogger,
|
|
7
|
+
import { d as TriggerTracer, g as Config, z as ProjectConfig, x as HandleErrorFunction, c as TaskMetadataWithFunctions, C as Clock, a as ClockTime, b as TaskCatalog } from '../../catalog-PA64uhhi.mjs';
|
|
8
|
+
export { O as OtelTaskLogger, A as logLevels } from '../../catalog-PA64uhhi.mjs';
|
|
9
9
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
10
10
|
import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
|
|
11
11
|
import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
|
|
@@ -4,8 +4,8 @@ export { TracingDiagnosticLogLevel, recordSpanException } from '../otel/index.js
|
|
|
4
4
|
import { p as TaskRunExecution, T as TaskRunExecutionResult } from '../../manager-M9GLDnhJ.js';
|
|
5
5
|
export { R as RuntimeManager } from '../../manager-M9GLDnhJ.js';
|
|
6
6
|
import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath } from '../../messages-AriaDDm0.js';
|
|
7
|
-
import { d as TriggerTracer, g as Config,
|
|
8
|
-
export { O as OtelTaskLogger,
|
|
7
|
+
import { d as TriggerTracer, g as Config, z as ProjectConfig, x as HandleErrorFunction, c as TaskMetadataWithFunctions, C as Clock, a as ClockTime, b as TaskCatalog } from '../../catalog-KJXg8k3W.js';
|
|
8
|
+
export { O as OtelTaskLogger, A as logLevels } from '../../catalog-KJXg8k3W.js';
|
|
9
9
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
10
10
|
import { LogRecordProcessor, LogRecord } from '@opentelemetry/sdk-logs';
|
|
11
11
|
import { SpanProcessor, Span } from '@opentelemetry/sdk-trace-base';
|
package/dist/v3/workers/index.js
CHANGED
|
@@ -1975,11 +1975,18 @@ function accessoryAttributes(accessory) {
|
|
|
1975
1975
|
__name(accessoryAttributes, "accessoryAttributes");
|
|
1976
1976
|
|
|
1977
1977
|
// src/v3/workers/taskExecutor.ts
|
|
1978
|
-
var _callRun, callRun_fn,
|
|
1978
|
+
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;
|
|
1979
1979
|
var _TaskExecutor = class _TaskExecutor {
|
|
1980
1980
|
constructor(task, options) {
|
|
1981
1981
|
__privateAdd(this, _callRun);
|
|
1982
|
-
__privateAdd(this,
|
|
1982
|
+
__privateAdd(this, _callInitFunctions);
|
|
1983
|
+
__privateAdd(this, _callConfigInit);
|
|
1984
|
+
__privateAdd(this, _callOnSuccessFunctions);
|
|
1985
|
+
__privateAdd(this, _callOnSuccessFunction);
|
|
1986
|
+
__privateAdd(this, _callOnFailureFunctions);
|
|
1987
|
+
__privateAdd(this, _callOnFailureFunction);
|
|
1988
|
+
__privateAdd(this, _callOnStartFunctions);
|
|
1989
|
+
__privateAdd(this, _callOnStartFunction);
|
|
1983
1990
|
__privateAdd(this, _callTaskCleanup);
|
|
1984
1991
|
__privateAdd(this, _handleError);
|
|
1985
1992
|
this.task = task;
|
|
@@ -2013,8 +2020,12 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2013
2020
|
try {
|
|
2014
2021
|
const payloadPacket = await conditionallyImportPacket(originalPacket, this._tracer);
|
|
2015
2022
|
parsedPayload = await parsePacket(payloadPacket);
|
|
2016
|
-
|
|
2023
|
+
if (execution.attempt.number === 1) {
|
|
2024
|
+
await __privateMethod(this, _callOnStartFunctions, callOnStartFunctions_fn).call(this, parsedPayload, ctx);
|
|
2025
|
+
}
|
|
2026
|
+
initOutput = await __privateMethod(this, _callInitFunctions, callInitFunctions_fn).call(this, parsedPayload, ctx);
|
|
2017
2027
|
const output = await __privateMethod(this, _callRun, callRun_fn).call(this, parsedPayload, ctx, initOutput);
|
|
2028
|
+
await __privateMethod(this, _callOnSuccessFunctions, callOnSuccessFunctions_fn).call(this, parsedPayload, output, ctx, initOutput);
|
|
2018
2029
|
try {
|
|
2019
2030
|
const stringifiedOutput = await stringifyIO(output);
|
|
2020
2031
|
const finalOutput = await conditionallyExportPacket(stringifiedOutput, `${execution.attempt.id}/output`, this._tracer);
|
|
@@ -2044,6 +2055,9 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2044
2055
|
try {
|
|
2045
2056
|
const handleErrorResult = await __privateMethod(this, _handleError, handleError_fn).call(this, execution, runError, parsedPayload, ctx);
|
|
2046
2057
|
recordSpanException(span, handleErrorResult.error ?? runError);
|
|
2058
|
+
if (handleErrorResult.status !== "retry") {
|
|
2059
|
+
await __privateMethod(this, _callOnFailureFunctions, callOnFailureFunctions_fn).call(this, parsedPayload, handleErrorResult.error ?? runError, ctx, initOutput);
|
|
2060
|
+
}
|
|
2047
2061
|
return {
|
|
2048
2062
|
id: execution.run.id,
|
|
2049
2063
|
ok: false,
|
|
@@ -2107,8 +2121,9 @@ callRun_fn = /* @__PURE__ */ __name(async function(payload, ctx, init) {
|
|
|
2107
2121
|
})
|
|
2108
2122
|
});
|
|
2109
2123
|
}, "#callRun");
|
|
2110
|
-
|
|
2111
|
-
|
|
2124
|
+
_callInitFunctions = new WeakSet();
|
|
2125
|
+
callInitFunctions_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
2126
|
+
await __privateMethod(this, _callConfigInit, callConfigInit_fn).call(this, payload1, ctx1);
|
|
2112
2127
|
const initFn = this.task.fns.init;
|
|
2113
2128
|
if (!initFn) {
|
|
2114
2129
|
return {};
|
|
@@ -2117,23 +2132,114 @@ callTaskInit_fn = /* @__PURE__ */ __name(async function(payload1, ctx1) {
|
|
|
2117
2132
|
return await initFn(payload1, {
|
|
2118
2133
|
ctx: ctx1
|
|
2119
2134
|
});
|
|
2135
|
+
}, {
|
|
2136
|
+
attributes: {
|
|
2137
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
}, "#callInitFunctions");
|
|
2141
|
+
_callConfigInit = new WeakSet();
|
|
2142
|
+
callConfigInit_fn = /* @__PURE__ */ __name(async function(payload2, ctx2) {
|
|
2143
|
+
const initFn = this._importedConfig?.init;
|
|
2144
|
+
if (!initFn) {
|
|
2145
|
+
return {};
|
|
2146
|
+
}
|
|
2147
|
+
return this._tracer.startActiveSpan("config.init", async (span) => {
|
|
2148
|
+
return await initFn(payload2, {
|
|
2149
|
+
ctx: ctx2
|
|
2150
|
+
});
|
|
2151
|
+
}, {
|
|
2152
|
+
attributes: {
|
|
2153
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2154
|
+
}
|
|
2120
2155
|
});
|
|
2121
|
-
}, "#
|
|
2156
|
+
}, "#callConfigInit");
|
|
2157
|
+
_callOnSuccessFunctions = new WeakSet();
|
|
2158
|
+
callOnSuccessFunctions_fn = /* @__PURE__ */ __name(async function(payload3, output, ctx3, initOutput) {
|
|
2159
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this.task.fns.onSuccess, "task.onSuccess", payload3, output, ctx3, initOutput);
|
|
2160
|
+
await __privateMethod(this, _callOnSuccessFunction, callOnSuccessFunction_fn).call(this, this._importedConfig?.onSuccess, "config.onSuccess", payload3, output, ctx3, initOutput);
|
|
2161
|
+
}, "#callOnSuccessFunctions");
|
|
2162
|
+
_callOnSuccessFunction = new WeakSet();
|
|
2163
|
+
callOnSuccessFunction_fn = /* @__PURE__ */ __name(async function(onSuccessFn, name, payload4, output1, ctx4, initOutput1) {
|
|
2164
|
+
if (!onSuccessFn) {
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
try {
|
|
2168
|
+
await this._tracer.startActiveSpan(name, async (span) => {
|
|
2169
|
+
return await onSuccessFn(payload4, output1, {
|
|
2170
|
+
ctx: ctx4,
|
|
2171
|
+
init: initOutput1
|
|
2172
|
+
});
|
|
2173
|
+
}, {
|
|
2174
|
+
attributes: {
|
|
2175
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
} catch {
|
|
2179
|
+
}
|
|
2180
|
+
}, "#callOnSuccessFunction");
|
|
2181
|
+
_callOnFailureFunctions = new WeakSet();
|
|
2182
|
+
callOnFailureFunctions_fn = /* @__PURE__ */ __name(async function(payload5, error, ctx5, initOutput2) {
|
|
2183
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this.task.fns.onFailure, "task.onFailure", payload5, error, ctx5, initOutput2);
|
|
2184
|
+
await __privateMethod(this, _callOnFailureFunction, callOnFailureFunction_fn).call(this, this._importedConfig?.onFailure, "config.onFailure", payload5, error, ctx5, initOutput2);
|
|
2185
|
+
}, "#callOnFailureFunctions");
|
|
2186
|
+
_callOnFailureFunction = new WeakSet();
|
|
2187
|
+
callOnFailureFunction_fn = /* @__PURE__ */ __name(async function(onFailureFn, name1, payload6, error1, ctx6, initOutput3) {
|
|
2188
|
+
if (!onFailureFn) {
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
try {
|
|
2192
|
+
return await this._tracer.startActiveSpan(name1, async (span) => {
|
|
2193
|
+
return await onFailureFn(payload6, error1, {
|
|
2194
|
+
ctx: ctx6,
|
|
2195
|
+
init: initOutput3
|
|
2196
|
+
});
|
|
2197
|
+
}, {
|
|
2198
|
+
attributes: {
|
|
2199
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2200
|
+
}
|
|
2201
|
+
});
|
|
2202
|
+
} catch (e) {
|
|
2203
|
+
}
|
|
2204
|
+
}, "#callOnFailureFunction");
|
|
2205
|
+
_callOnStartFunctions = new WeakSet();
|
|
2206
|
+
callOnStartFunctions_fn = /* @__PURE__ */ __name(async function(payload7, ctx7) {
|
|
2207
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this._importedConfig?.onStart, "config.onStart", payload7, ctx7, {});
|
|
2208
|
+
await __privateMethod(this, _callOnStartFunction, callOnStartFunction_fn).call(this, this.task.fns.onStart, "task.onStart", payload7, ctx7, {});
|
|
2209
|
+
}, "#callOnStartFunctions");
|
|
2210
|
+
_callOnStartFunction = new WeakSet();
|
|
2211
|
+
callOnStartFunction_fn = /* @__PURE__ */ __name(async function(onStartFn, name2, payload8, ctx8, initOutput4) {
|
|
2212
|
+
if (!onStartFn) {
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
try {
|
|
2216
|
+
await this._tracer.startActiveSpan(name2, async (span) => {
|
|
2217
|
+
return await onStartFn(payload8, {
|
|
2218
|
+
ctx: ctx8
|
|
2219
|
+
});
|
|
2220
|
+
}, {
|
|
2221
|
+
attributes: {
|
|
2222
|
+
[SemanticInternalAttributes.STYLE_ICON]: "function"
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
} catch {
|
|
2226
|
+
}
|
|
2227
|
+
}, "#callOnStartFunction");
|
|
2122
2228
|
_callTaskCleanup = new WeakSet();
|
|
2123
|
-
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(
|
|
2229
|
+
callTaskCleanup_fn = /* @__PURE__ */ __name(async function(payload9, ctx9, init1) {
|
|
2124
2230
|
const cleanupFn = this.task.fns.cleanup;
|
|
2125
2231
|
if (!cleanupFn) {
|
|
2126
2232
|
return;
|
|
2127
2233
|
}
|
|
2128
2234
|
return this._tracer.startActiveSpan("cleanup", async (span) => {
|
|
2129
|
-
return await cleanupFn(
|
|
2130
|
-
ctx:
|
|
2235
|
+
return await cleanupFn(payload9, {
|
|
2236
|
+
ctx: ctx9,
|
|
2131
2237
|
init: init1
|
|
2132
2238
|
});
|
|
2133
2239
|
});
|
|
2134
2240
|
}, "#callTaskCleanup");
|
|
2135
2241
|
_handleError = new WeakSet();
|
|
2136
|
-
handleError_fn = /* @__PURE__ */ __name(async function(execution,
|
|
2242
|
+
handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payload10, ctx10) {
|
|
2137
2243
|
const retriesConfig = this._importedConfig?.retries ?? this._config.retries;
|
|
2138
2244
|
const retry = this.task.retry ?? retriesConfig?.default;
|
|
2139
2245
|
if (!retry) {
|
|
@@ -2148,13 +2254,13 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error, payload
|
|
|
2148
2254
|
};
|
|
2149
2255
|
}
|
|
2150
2256
|
return this._tracer.startActiveSpan("handleError()", async (span) => {
|
|
2151
|
-
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(
|
|
2152
|
-
ctx:
|
|
2257
|
+
const handleErrorResult = this.task.fns.handleError ? await this.task.fns.handleError(payload10, error2, {
|
|
2258
|
+
ctx: ctx10,
|
|
2153
2259
|
retry,
|
|
2154
2260
|
retryDelayInMs: delay,
|
|
2155
2261
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|
|
2156
|
-
}) : this._importedConfig ? await this._handleErrorFn?.(
|
|
2157
|
-
ctx:
|
|
2262
|
+
}) : this._importedConfig ? await this._handleErrorFn?.(payload10, error2, {
|
|
2263
|
+
ctx: ctx10,
|
|
2158
2264
|
retry,
|
|
2159
2265
|
retryDelayInMs: delay,
|
|
2160
2266
|
retryAt: delay ? new Date(Date.now() + delay) : void 0
|