@mastra/temporal 0.6.4-alpha.8 → 0.6.4-alpha.9
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/temporal-workflow-runtime.mjs +34 -7
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +1 -1
- package/package.json +4 -4
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
defineSignal,
|
|
7
7
|
executeChild,
|
|
8
8
|
isCancellation,
|
|
9
|
+
patched,
|
|
9
10
|
proxyActivities,
|
|
10
11
|
log,
|
|
11
12
|
setHandler,
|
|
@@ -15,6 +16,12 @@ import {
|
|
|
15
16
|
const resumeSignal = defineSignal('mastra.resume');
|
|
16
17
|
const statusQuery = defineQuery('mastra.status');
|
|
17
18
|
|
|
19
|
+
// A date-like `.sleepUntil()` identifier (for example "jan1") used to be read as a literal
|
|
20
|
+
// deadline and started a Timer. Runs recorded before that was fixed carry a Timer in their history,
|
|
21
|
+
// so the two behaviors are keyed off the recorded history by this patch id: those runs keep
|
|
22
|
+
// replaying as Timers, while new runs schedule the deadline activity.
|
|
23
|
+
const SLEEP_UNTIL_ACTIVITY_PATCH = 'mastra.sleep-until-identifier-activity';
|
|
24
|
+
|
|
18
25
|
// The step error an Activity or child Workflow put in its failure details. Failures without them
|
|
19
26
|
// (timeouts, Activities from an older Worker) give the innermost cause's type and message.
|
|
20
27
|
function readStepFailure(error) {
|
|
@@ -268,12 +275,20 @@ export class TemporalExecutionEngine {
|
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
case 'sleepUntil': {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
278
|
+
let date;
|
|
279
|
+
|
|
280
|
+
if (entry.date != null) {
|
|
281
|
+
date = new Date(entry.date);
|
|
282
|
+
} else if (entry.fn && entry.legacyDate != null && !patched(SLEEP_UNTIL_ACTIVITY_PATCH)) {
|
|
283
|
+
// Replaying a run recorded before the fix: that run started a Timer for this date-like
|
|
284
|
+
// identifier name, so scheduling the activity here would fail the Workflow Task as
|
|
285
|
+
// non-deterministic. `legacyDate` is the deadline that same name used to resolve to.
|
|
286
|
+
date = new Date(entry.legacyDate);
|
|
287
|
+
} else if (entry.fn) {
|
|
288
|
+
date = new Date(await this.activityHandle[entry.fn](this.activityParams(inputData)));
|
|
289
|
+
} else {
|
|
290
|
+
date = new Date();
|
|
291
|
+
}
|
|
277
292
|
log.info('sleepUntil', { id: entry.id, date: date.toISOString() });
|
|
278
293
|
const duration = Math.max(0, date.getTime() - Date.now());
|
|
279
294
|
await sleep(duration);
|
|
@@ -484,7 +499,19 @@ export function createWorkflow(workflowId, options) {
|
|
|
484
499
|
return workflow;
|
|
485
500
|
},
|
|
486
501
|
sleepUntil(dateOrFnId) {
|
|
487
|
-
if (dateOrFnId
|
|
502
|
+
if (dateOrFnId && typeof dateOrFnId === 'object' && typeof dateOrFnId.fn === 'string') {
|
|
503
|
+
// Transform-emitted `{ fn }` wrapper: the identifier is always a deadline activity, even when
|
|
504
|
+
// its name parses as a date (e.g. "jan1"), which the string branch below would misread.
|
|
505
|
+
// Runs recorded before that fix read such a name as a literal deadline, so carry the
|
|
506
|
+
// deadline it used to resolve to for the replay-safe fallback in executeEntry.
|
|
507
|
+
const name = dateOrFnId.fn;
|
|
508
|
+
stepFlow.push({
|
|
509
|
+
type: 'sleepUntil',
|
|
510
|
+
id: nextId('sleepUntil'),
|
|
511
|
+
fn: name,
|
|
512
|
+
...(isNaN(Date.parse(name)) ? {} : { legacyDate: new Date(name).toISOString() }),
|
|
513
|
+
});
|
|
514
|
+
} else if (dateOrFnId instanceof Date) {
|
|
488
515
|
stepFlow.push({
|
|
489
516
|
type: 'sleepUntil',
|
|
490
517
|
id: nextId('sleepUntil'),
|
package/dist/worker.cjs
CHANGED
|
@@ -908,7 +908,7 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
|
|
|
908
908
|
if (_babel_types.isStringLiteral(arg) || _babel_types.isNumericLiteral(arg)) return rewritten([_babel_types.cloneNode(arg, true)]);
|
|
909
909
|
const name = getWorkflowStepName(arg, stepBindings);
|
|
910
910
|
if (!name) throw new Error(`.sleepUntil() in ${workflowName} (${filePath}) must be a Date, string/number literal, or an identifier`);
|
|
911
|
-
return rewritten([_babel_types.stringLiteral(name)]);
|
|
911
|
+
return rewritten([_babel_types.objectExpression([_babel_types.objectProperty(_babel_types.identifier("fn"), _babel_types.stringLiteral(name))])]);
|
|
912
912
|
}
|
|
913
913
|
case "parallel": {
|
|
914
914
|
const arg = argNode(0);
|
package/dist/worker.js
CHANGED
|
@@ -884,7 +884,7 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
|
|
|
884
884
|
if (t.isStringLiteral(arg) || t.isNumericLiteral(arg)) return rewritten([t.cloneNode(arg, true)]);
|
|
885
885
|
const name = getWorkflowStepName(arg, stepBindings);
|
|
886
886
|
if (!name) throw new Error(`.sleepUntil() in ${workflowName} (${filePath}) must be a Date, string/number literal, or an identifier`);
|
|
887
|
-
return rewritten([t.stringLiteral(name)]);
|
|
887
|
+
return rewritten([t.objectExpression([t.objectProperty(t.identifier("fn"), t.stringLiteral(name))])]);
|
|
888
888
|
}
|
|
889
889
|
case "parallel": {
|
|
890
890
|
const arg = argNode(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/temporal",
|
|
3
|
-
"version": "0.6.4-alpha.
|
|
3
|
+
"version": "0.6.4-alpha.9",
|
|
4
4
|
"description": "Mastra Temporal workflows integration - run Mastra workflows on the Temporal durable execution platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@temporalio/worker": "^1.24.0",
|
|
52
52
|
"@temporalio/workflow": "^1.24.0",
|
|
53
53
|
"rollup": "^4.65.0",
|
|
54
|
-
"@mastra/deployer": "1.87.0-alpha.
|
|
54
|
+
"@mastra/deployer": "1.87.0-alpha.9"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@mastra/core": ">=1.85.1-0 <2.0.0-0",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"vitest": "5.1.0",
|
|
65
65
|
"webpack": "^5.112.2",
|
|
66
66
|
"zod": "^4.6.7",
|
|
67
|
-
"@internal/lint": "0.0.152",
|
|
68
67
|
"@internal/types-builder": "0.0.127",
|
|
69
68
|
"@internal/workflow-test-utils": "0.0.31",
|
|
70
|
-
"@mastra/core": "1.87.0-alpha.
|
|
69
|
+
"@mastra/core": "1.87.0-alpha.9",
|
|
70
|
+
"@internal/lint": "0.0.152"
|
|
71
71
|
},
|
|
72
72
|
"homepage": "https://mastra.ai",
|
|
73
73
|
"repository": {
|