@temporalio/workflow 1.14.1 → 1.15.0
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/lib/cancellation-scope.d.ts +2 -2
- package/lib/cancellation-scope.js +2 -2
- package/lib/flags.js +1 -1
- package/lib/flags.js.map +1 -1
- package/lib/global-overrides.js +6 -6
- package/lib/global-overrides.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +16 -1
- package/lib/interfaces.d.ts +73 -30
- package/lib/interfaces.js +54 -14
- package/lib/interfaces.js.map +1 -1
- package/lib/internals.d.ts +2 -1
- package/lib/internals.js +24 -7
- package/lib/internals.js.map +1 -1
- package/lib/metrics.js +4 -0
- package/lib/metrics.js.map +1 -1
- package/lib/nexus.d.ts +51 -0
- package/lib/nexus.js +68 -8
- package/lib/nexus.js.map +1 -1
- package/lib/workflow.js +11 -11
- package/lib/workflow.js.map +1 -1
- package/package.json +7 -8
- package/src/cancellation-scope.ts +2 -2
- package/src/flags.ts +1 -1
- package/src/global-attributes.ts +3 -3
- package/src/global-overrides.ts +6 -6
- package/src/index.ts +11 -6
- package/src/interceptors.ts +18 -1
- package/src/interfaces.ts +84 -38
- package/src/internals.ts +28 -8
- package/src/metrics.ts +7 -0
- package/src/nexus.ts +84 -8
- package/src/workflow.ts +11 -11
|
@@ -24,7 +24,7 @@ export interface CancellationScopeOptions {
|
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Cancellation Scopes provide the mechanic by which a Workflow may gracefully handle incoming requests for cancellation
|
|
27
|
-
* (e.g. in response to {@link WorkflowHandle.cancel} or through the UI or CLI), as well as request
|
|
27
|
+
* (e.g. in response to {@link WorkflowHandle.cancel} or through the UI or CLI), as well as request cancellation of
|
|
28
28
|
* cancellable operations it owns (e.g. Activities, Timers, Child Workflows, etc).
|
|
29
29
|
*
|
|
30
30
|
* Cancellation Scopes form a tree, with the Workflow's main function running in the root scope of that tree.
|
|
@@ -46,7 +46,7 @@ export interface CancellationScopeOptions {
|
|
|
46
46
|
* ```ts
|
|
47
47
|
* async function myWorkflow(...): Promise<void> {
|
|
48
48
|
* try {
|
|
49
|
-
* // This activity runs in the root cancellation scope. Therefore, a
|
|
49
|
+
* // This activity runs in the root cancellation scope. Therefore, a cancellation request on
|
|
50
50
|
* // the Workflow execution (e.g. through the UI or CLI) automatically propagates to this
|
|
51
51
|
* // activity. Assuming that the activity properly handle the cancellation request, then the
|
|
52
52
|
* // call below will throw an `ActivityFailure` exception, with `cause` sets to an
|
|
@@ -15,7 +15,7 @@ exports.AsyncLocalStorage = globalThis.AsyncLocalStorage ?? class {
|
|
|
15
15
|
const NO_PARENT = Symbol('NO_PARENT');
|
|
16
16
|
/**
|
|
17
17
|
* Cancellation Scopes provide the mechanic by which a Workflow may gracefully handle incoming requests for cancellation
|
|
18
|
-
* (e.g. in response to {@link WorkflowHandle.cancel} or through the UI or CLI), as well as request
|
|
18
|
+
* (e.g. in response to {@link WorkflowHandle.cancel} or through the UI or CLI), as well as request cancellation of
|
|
19
19
|
* cancellable operations it owns (e.g. Activities, Timers, Child Workflows, etc).
|
|
20
20
|
*
|
|
21
21
|
* Cancellation Scopes form a tree, with the Workflow's main function running in the root scope of that tree.
|
|
@@ -37,7 +37,7 @@ const NO_PARENT = Symbol('NO_PARENT');
|
|
|
37
37
|
* ```ts
|
|
38
38
|
* async function myWorkflow(...): Promise<void> {
|
|
39
39
|
* try {
|
|
40
|
-
* // This activity runs in the root cancellation scope. Therefore, a
|
|
40
|
+
* // This activity runs in the root cancellation scope. Therefore, a cancellation request on
|
|
41
41
|
* // the Workflow execution (e.g. through the UI or CLI) automatically propagates to this
|
|
42
42
|
* // activity. Assuming that the activity properly handle the cancellation request, then the
|
|
43
43
|
* // call below will throw an `ActivityFailure` exception, with `cause` sets to an
|
package/lib/flags.js
CHANGED
|
@@ -88,7 +88,7 @@ function assertValidFlag(id) {
|
|
|
88
88
|
}
|
|
89
89
|
function buildIdSdkVersionMatches(version) {
|
|
90
90
|
const regex = new RegExp(`^@temporalio/worker@(${version.source})[+]`);
|
|
91
|
-
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId); // eslint-disable-line
|
|
91
|
+
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId); // eslint-disable-line @typescript-eslint/no-deprecated
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Creates an `AltConditionFn` that checks if the SDK version is equal to or after the provided version.
|
package/lib/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":";;;AAgGA,0CAEC;AA1FD,MAAM,aAAa,GAAyB,IAAI,GAAG,EAAE,CAAC;AAEzC,QAAA,QAAQ,GAAG;IACtB;;;;;;;;;;;OAWG;IACH,8CAA8C,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC,CAAC;IAE9G;;;;;;;;;;;;;;;;;;;OAmBG;IACH,0CAA0C,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC,CAAC;IAE1G;;;;;;;;OAQG;IACH,6CAA6C,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAElH;;;;;;OAMG;IACH,8CAA8C,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAEnH;;;;;;;;;OASG;IACH,yCAAyC,EAAE,UAAU,CAAC,C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M,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,CAAS,EAAE,CAAS;IACzC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/lib/global-overrides.js
CHANGED
|
@@ -36,7 +36,7 @@ function overrideGlobals() {
|
|
|
36
36
|
global.Date.parse = OriginalDate.parse.bind(OriginalDate);
|
|
37
37
|
global.Date.UTC = OriginalDate.UTC.bind(OriginalDate);
|
|
38
38
|
global.Date.prototype = OriginalDate.prototype;
|
|
39
|
-
const
|
|
39
|
+
const timeoutCancellationScopes = new Map();
|
|
40
40
|
/**
|
|
41
41
|
* @param ms sleep duration - number of milliseconds. If given a negative number, value will be set to 1.
|
|
42
42
|
*/
|
|
@@ -49,13 +49,13 @@ function overrideGlobals() {
|
|
|
49
49
|
const timerScope = new cancellation_scope_1.CancellationScope({ cancellable: true });
|
|
50
50
|
const sleepPromise = timerScope.run(() => (0, workflow_1.sleep)(ms));
|
|
51
51
|
sleepPromise.then(() => {
|
|
52
|
-
|
|
52
|
+
timeoutCancellationScopes.delete(seq);
|
|
53
53
|
cb(...args);
|
|
54
54
|
}, () => {
|
|
55
|
-
|
|
55
|
+
timeoutCancellationScopes.delete(seq);
|
|
56
56
|
});
|
|
57
57
|
(0, stack_helpers_1.untrackPromise)(sleepPromise);
|
|
58
|
-
|
|
58
|
+
timeoutCancellationScopes.set(seq, timerScope);
|
|
59
59
|
return seq;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -75,9 +75,9 @@ function overrideGlobals() {
|
|
|
75
75
|
};
|
|
76
76
|
global.clearTimeout = function (handle) {
|
|
77
77
|
const activator = (0, global_attributes_1.getActivator)();
|
|
78
|
-
const timerScope =
|
|
78
|
+
const timerScope = timeoutCancellationScopes.get(handle);
|
|
79
79
|
if (timerScope) {
|
|
80
|
-
|
|
80
|
+
timeoutCancellationScopes.delete(handle);
|
|
81
81
|
timerScope.cancel();
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-overrides.js","sourceRoot":"","sources":["../src/global-overrides.ts"],"names":[],"mappings":";;AAgBA,0CA2FC;AA3GD;;;;GAIG;AACH,sDAAqD;AACrD,6DAAyD;AACzD,qCAAqD;AACrD,2DAAmD;AACnD,mCAAmC;AACnC,yCAAmC;AACnC,mDAAiD;AAEjD,MAAM,MAAM,GAAG,UAAiB,CAAC;AACjC,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;AAErC,SAAgB,eAAe;IAC7B,0GAA0G;IAC1G,+EAA+E;IAC/E,MAAM,CAAC,OAAO,GAAG;QACf,MAAM,IAAI,kCAAyB,CAAC,wEAAwE,CAAC,CAAC;IAChH,CAAC,CAAC;IACF,MAAM,CAAC,oBAAoB,GAAG;QAC5B,MAAM,IAAI,kCAAyB,CACjC,qFAAqF,CACtF,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,CAAC,IAAI,GAAG,UAAU,GAAG,IAAe;QACxC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO,IAAK,YAAoB,CAAC,GAAG,IAAI,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M,CAAC,CAAC;YAC3C,SAAS,CAAC,WAAW,CAAC;gBACpB,WAAW,EAAE;oBACX,GAAG,EAAE,MAAM;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,4DAA4D;IAC5D,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,gCAAY,GAAE,CAAC,MAAM,EAAE,CAAC;AAC9C,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
*
|
|
49
49
|
* @module
|
|
50
50
|
*/
|
|
51
|
-
export { ActivityCancellationType, ActivityFailure, ActivityOptions, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, defaultPayloadConverter, PayloadConverter, RetryPolicy, rootCause, SearchAttributes, // eslint-disable-line
|
|
52
|
-
SearchAttributeValue, // eslint-disable-line
|
|
51
|
+
export { ActivityCancellationType, ActivityFailure, ActivityOptions, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, defaultPayloadConverter, PayloadConverter, RetryPolicy, rootCause, SearchAttributes, // eslint-disable-line @typescript-eslint/no-deprecated
|
|
52
|
+
SearchAttributeValue, // eslint-disable-line @typescript-eslint/no-deprecated
|
|
53
53
|
ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
54
54
|
export * from '@temporalio/common/lib/errors';
|
|
55
|
-
export { ActivityFunction, ActivityInterface, // eslint-disable-line
|
|
55
|
+
export { ActivityFunction, ActivityInterface, // eslint-disable-line @typescript-eslint/no-deprecated
|
|
56
56
|
Payload, QueryDefinition, SignalDefinition, UntypedActivities, Workflow, WorkflowQueryType, WorkflowResultType, WorkflowReturnType, WorkflowSignalType, } from '@temporalio/common/lib/interfaces';
|
|
57
57
|
export * from '@temporalio/common/lib/workflow-handle';
|
|
58
58
|
export * from '@temporalio/common/lib/workflow-options';
|
|
@@ -66,7 +66,7 @@ export { Trigger } from './trigger';
|
|
|
66
66
|
export * from './workflow';
|
|
67
67
|
export { ChildWorkflowHandle, ExternalWorkflowHandle } from './workflow-handle';
|
|
68
68
|
export { metricMeter } from './metrics';
|
|
69
|
-
export { createNexusClient, NexusClientOptions, NexusClient, NexusOperationHandle } from './nexus';
|
|
69
|
+
export { createNexusClient, NexusClientOptions, NexusClient, NexusOperationHandle, NexusOperationCancellationType, } from './nexus';
|
|
70
70
|
export {
|
|
71
71
|
/**
|
|
72
72
|
* @deprecated Do not use LoggerSinks directly. To log from Workflow code, use the `log` object
|
package/lib/index.js
CHANGED
|
@@ -64,7 +64,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
64
64
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
65
65
|
};
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.createNexusClient = exports.metricMeter = exports.Trigger = exports.log = exports.proxySinks = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.CancellationScope = exports.AsyncLocalStorage = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = exports.ActivityCancellationType = void 0;
|
|
67
|
+
exports.NexusOperationCancellationType = exports.createNexusClient = exports.metricMeter = exports.Trigger = exports.log = exports.proxySinks = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.CancellationScope = exports.AsyncLocalStorage = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = exports.ActivityCancellationType = void 0;
|
|
68
68
|
var common_1 = require("@temporalio/common");
|
|
69
69
|
Object.defineProperty(exports, "ActivityCancellationType", { enumerable: true, get: function () { return common_1.ActivityCancellationType; } });
|
|
70
70
|
Object.defineProperty(exports, "ActivityFailure", { enumerable: true, get: function () { return common_1.ActivityFailure; } });
|
|
@@ -100,4 +100,5 @@ var metrics_1 = require("./metrics");
|
|
|
100
100
|
Object.defineProperty(exports, "metricMeter", { enumerable: true, get: function () { return metrics_1.metricMeter; } });
|
|
101
101
|
var nexus_1 = require("./nexus");
|
|
102
102
|
Object.defineProperty(exports, "createNexusClient", { enumerable: true, get: function () { return nexus_1.createNexusClient; } });
|
|
103
|
+
Object.defineProperty(exports, "NexusOperationCancellationType", { enumerable: true, get: function () { return nexus_1.NexusOperationCancellationType; } });
|
|
103
104
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;;;;;;;;;;;;;;;;;AAEH,6CAiB4B;AAhB1B,kHAAA,wBAAwB,OAAA;AACxB,yGAAA,eAAe,OAAA;AAEf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,iHAAA,uBAAuB,OAAA;AAGvB,mGAAA,SAAS,OAAA;AAGT,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AAEhB,gEAA8C;AAc9C,yEAAuD;AACvD,0EAAwD;AACxD,2DAAsG;AAA7F,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAC7C,2CAAyB;AACzB,iDAA+B;AAC/B,2CAesB;AAdpB,2HAAA,6BAA6B,OAAA;AAE7B,2GAAA,aAAa,OAAA;AAKb,+GAAA,iBAAiB,OAAA;AAQnB,iCAA0E;AAAjE,mGAAA,UAAU,OAAA;AACnB,+BAA6B;AAApB,2FAAA,GAAG,OAAA;AACZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B;AAE3B,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;;;;;;;;;;;;;;;;;AAEH,6CAiB4B;AAhB1B,kHAAA,wBAAwB,OAAA;AACxB,yGAAA,eAAe,OAAA;AAEf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,iHAAA,uBAAuB,OAAA;AAGvB,mGAAA,SAAS,OAAA;AAGT,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AAEhB,gEAA8C;AAc9C,yEAAuD;AACvD,0EAAwD;AACxD,2DAAsG;AAA7F,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAC7C,2CAAyB;AACzB,iDAA+B;AAC/B,2CAesB;AAdpB,2HAAA,6BAA6B,OAAA;AAE7B,2GAAA,aAAa,OAAA;AAKb,+GAAA,iBAAiB,OAAA;AAQnB,iCAA0E;AAAjE,mGAAA,UAAU,OAAA;AACnB,+BAA6B;AAApB,2FAAA,GAAG,OAAA;AACZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B;AAE3B,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,iCAMiB;AALf,0GAAA,iBAAiB,OAAA;AAIjB,uHAAA,8BAA8B,OAAA"}
|
package/lib/interceptors.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ActivityOptions, Duration, Headers, LocalActivityOptions, MetricTags, Next, Timestamp, WorkflowExecution } from '@temporalio/common';
|
|
7
7
|
import type { coresdk } from '@temporalio/proto';
|
|
8
|
-
import { ChildWorkflowOptionsWithDefaults, ContinueAsNewOptions } from './interfaces';
|
|
8
|
+
import type { ChildWorkflowOptionsWithDefaults, ContinueAsNewOptions } from './interfaces';
|
|
9
|
+
import type { NexusOperationCancellationType } from './nexus';
|
|
9
10
|
export { Next, Headers };
|
|
10
11
|
/**
|
|
11
12
|
* A function that instantiates {@link WorkflowInterceptors}.
|
|
@@ -222,6 +223,20 @@ export interface StartNexusOperationOptions {
|
|
|
222
223
|
* Optional: defaults to the maximum allowed by the Temporal server.
|
|
223
224
|
*/
|
|
224
225
|
readonly scheduleToCloseTimeout?: Duration;
|
|
226
|
+
/**
|
|
227
|
+
* Determines:
|
|
228
|
+
* - whether cancellation requests should be propagated from the Workflow to the Nexus Operation
|
|
229
|
+
* - whether and when should the Operation's cancellation be reported back to the Workflow
|
|
230
|
+
* (i.e. at which moment should the operation's result promise fail with a `NexusOperationFailure`,
|
|
231
|
+
* with `cause` set to a `CancelledFailure`).
|
|
232
|
+
*
|
|
233
|
+
* Note that this setting only applies to cancellation originating from an external request for the
|
|
234
|
+
* Workflow itself, or from internal cancellation of the `CancellationScope` in which the
|
|
235
|
+
* Operation call was made.
|
|
236
|
+
*
|
|
237
|
+
* @default WAIT_CANCELLATION_COMPLETED
|
|
238
|
+
*/
|
|
239
|
+
readonly cancellationType?: NexusOperationCancellationType;
|
|
225
240
|
/**
|
|
226
241
|
* A fixed, single-line summary for this Nexus Operation that may appear in the UI/CLI.
|
|
227
242
|
* This can be in single-line Temporal markdown format.
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -162,8 +162,6 @@ export interface WorkflowInfo {
|
|
|
162
162
|
* executing this task for the first time and has a Deployment Version set, then its ID will be
|
|
163
163
|
* used. This value may change over the lifetime of the workflow run, but is deterministic and
|
|
164
164
|
* safe to use for branching.
|
|
165
|
-
*
|
|
166
|
-
* @experimental Deployment based versioning is experimental and may change in the future.
|
|
167
165
|
*/
|
|
168
166
|
readonly currentDeploymentVersion?: WorkerDeploymentVersion;
|
|
169
167
|
readonly unsafe: UnsafeWorkflowInfo;
|
|
@@ -185,7 +183,21 @@ export interface UnsafeWorkflowInfo {
|
|
|
185
183
|
* Task and stay constant for the duration of the Task and during replay.
|
|
186
184
|
*/
|
|
187
185
|
readonly now: () => number;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the workflow is currently replaying.
|
|
188
|
+
*/
|
|
188
189
|
readonly isReplaying: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Whether the workflow is currently replaying history events.
|
|
192
|
+
*
|
|
193
|
+
* This is similar to {@link isReplaying}, but returns `false` during query handlers and update
|
|
194
|
+
* validators, which are live read-only operations that should not be considered as replaying
|
|
195
|
+
* history events.
|
|
196
|
+
*
|
|
197
|
+
* When this property is true, workflow log messages are suppressed and sinks defined with
|
|
198
|
+
* callDuringReplay=false won't get processed.
|
|
199
|
+
*/
|
|
200
|
+
readonly isReplayingHistoryEvents: boolean;
|
|
189
201
|
}
|
|
190
202
|
/**
|
|
191
203
|
* Information about a workflow update.
|
|
@@ -264,50 +276,74 @@ export interface ContinueAsNewOptions {
|
|
|
264
276
|
*
|
|
265
277
|
* @default 'COMPATIBLE'
|
|
266
278
|
*
|
|
267
|
-
* @deprecated
|
|
268
|
-
* @experimental The Worker Versioning API is still being designed. Major changes are expected.
|
|
279
|
+
* @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
|
|
269
280
|
*/
|
|
270
281
|
versioningIntent?: VersioningIntent;
|
|
271
282
|
}
|
|
272
283
|
/**
|
|
273
|
-
*
|
|
274
|
-
* - whether cancellation requests
|
|
275
|
-
* - whether and when
|
|
276
|
-
* {@link ChildWorkflowHandle.result}
|
|
284
|
+
* Determines:
|
|
285
|
+
* - whether cancellation requests should be propagated from the Parent Workflow to the Child, and
|
|
286
|
+
* - whether and when should the Child's cancellation be reported back to the Parent Workflow
|
|
287
|
+
* (i.e. at which moment should the {@link executeChild}'s or {@link ChildWorkflowHandle.result}'s
|
|
288
|
+
* promise fail with a `ChildWorkflowFailure`, with `cause` set to a `CancelledFailure`).
|
|
289
|
+
*
|
|
290
|
+
* Note that this setting only applies to cancellation originating from an external request for the
|
|
291
|
+
* Parent Workflow itself, or from internal cancellation of the `CancellationScope` in which the
|
|
292
|
+
* Child Workflow call was made. Eventual Cancellation of a Child Workflow on completion of the
|
|
293
|
+
* Parent Workflow is controlled by the {@link ParentClosePolicy} setting.
|
|
277
294
|
*
|
|
278
|
-
* @default
|
|
295
|
+
* @default ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED
|
|
279
296
|
*/
|
|
280
|
-
export type ChildWorkflowCancellationType = (typeof ChildWorkflowCancellationType)[keyof typeof ChildWorkflowCancellationType];
|
|
281
297
|
export declare const ChildWorkflowCancellationType: {
|
|
282
298
|
/**
|
|
283
|
-
*
|
|
299
|
+
* Do not propagate cancellation requests to the Child, and immediately report cancellation
|
|
300
|
+
* to the caller.
|
|
284
301
|
*/
|
|
285
302
|
readonly ABANDON: "ABANDON";
|
|
286
303
|
/**
|
|
287
|
-
*
|
|
304
|
+
* Propagate cancellation request from the Parent Workflow to the Child, yet _immediately_ report
|
|
305
|
+
* cancellation to the caller, i.e. without waiting for the server to confirm the cancellation
|
|
306
|
+
* request.
|
|
307
|
+
*
|
|
308
|
+
* Note that this cancellation type provides no guarantee, from the Parent-side, that the
|
|
309
|
+
* cancellation request will actually be atomically added to the Child workflow's history.
|
|
310
|
+
* In particular, the Child may complete (either successfully or uncessfully) before the
|
|
311
|
+
* cancellation is delivered, resulting in a situation where the Parent workflow thinks its child
|
|
312
|
+
* was cancelled, but the child actually completed successfully.
|
|
313
|
+
*
|
|
314
|
+
* To guarantee that the Child will eventually be notified of the cancellation request,
|
|
315
|
+
* use {@link WAIT_CANCELLATION_REQUESTED}.
|
|
288
316
|
*/
|
|
289
317
|
readonly TRY_CANCEL: "TRY_CANCEL";
|
|
290
318
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* ignore the cancellation request, in which case an error might be thrown with a different cause, or the Child may
|
|
294
|
-
* complete successfully.
|
|
319
|
+
* Propagate cancellation request from the Parent Workflow to the Child, then wait for the server
|
|
320
|
+
* to confirm that the Child Workflow cancellation request was recorded in its history.
|
|
295
321
|
*
|
|
296
|
-
*
|
|
322
|
+
* This cancellation type guarantees that the Child will eventually be notified of the
|
|
323
|
+
* cancellation request (that is, unless the Child terminates inbetween due to unexpected causes).
|
|
297
324
|
*/
|
|
298
|
-
readonly
|
|
325
|
+
readonly WAIT_CANCELLATION_REQUESTED: "WAIT_CANCELLATION_REQUESTED";
|
|
299
326
|
/**
|
|
300
|
-
*
|
|
327
|
+
* Propagate cancellation request from the Parent Workflow to the Child, then wait for completion
|
|
328
|
+
* of the Child Workflow.
|
|
329
|
+
*
|
|
330
|
+
* The Child may respect cancellation, in which case the Parent's `executeChild` or
|
|
331
|
+
* `ChildWorkflowHandle.result` promise will fail with a `ChildWorkflowFailure`, with `cause`
|
|
332
|
+
* set to a `CancelledFailure`. On the other hand, the Child may ignore the cancellation request,
|
|
333
|
+
* in which case the corresponding promise will either resolve with a result (if Child completed
|
|
334
|
+
* successfully) or reject with a different cause (if Child completed uncessfully).
|
|
335
|
+
*
|
|
336
|
+
* @default
|
|
301
337
|
*/
|
|
302
|
-
readonly
|
|
338
|
+
readonly WAIT_CANCELLATION_COMPLETED: "WAIT_CANCELLATION_COMPLETED";
|
|
303
339
|
};
|
|
304
|
-
export
|
|
340
|
+
export type ChildWorkflowCancellationType = (typeof ChildWorkflowCancellationType)[keyof typeof ChildWorkflowCancellationType];
|
|
341
|
+
export declare const encodeChildWorkflowCancellationType: (input: coresdk.child_workflow.ChildWorkflowCancellationType | import("@temporalio/common/lib/type-helpers").RemovePrefix<"", "ABANDON" | "TRY_CANCEL" | "WAIT_CANCELLATION_REQUESTED" | "WAIT_CANCELLATION_COMPLETED"> | null | undefined) => coresdk.child_workflow.ChildWorkflowCancellationType | undefined, decodeChildWorkflowCancellationType: (input: coresdk.child_workflow.ChildWorkflowCancellationType | null | undefined) => import("@temporalio/common/lib/type-helpers").RemovePrefix<"", "ABANDON" | "TRY_CANCEL" | "WAIT_CANCELLATION_REQUESTED" | "WAIT_CANCELLATION_COMPLETED"> | undefined;
|
|
305
342
|
/**
|
|
306
343
|
* How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
|
|
307
344
|
*
|
|
308
345
|
* @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy}
|
|
309
346
|
*/
|
|
310
|
-
export type ParentClosePolicy = (typeof ParentClosePolicy)[keyof typeof ParentClosePolicy];
|
|
311
347
|
export declare const ParentClosePolicy: {
|
|
312
348
|
/**
|
|
313
349
|
* When the Parent is Closed, the Child is Terminated.
|
|
@@ -348,6 +384,7 @@ export declare const ParentClosePolicy: {
|
|
|
348
384
|
*/
|
|
349
385
|
readonly PARENT_CLOSE_POLICY_REQUEST_CANCEL: "REQUEST_CANCEL";
|
|
350
386
|
};
|
|
387
|
+
export type ParentClosePolicy = (typeof ParentClosePolicy)[keyof typeof ParentClosePolicy];
|
|
351
388
|
export declare const encodeParentClosePolicy: (input: "ABANDON" | "TERMINATE" | "REQUEST_CANCEL" | "PARENT_CLOSE_POLICY_TERMINATE" | "PARENT_CLOSE_POLICY_ABANDON" | "PARENT_CLOSE_POLICY_REQUEST_CANCEL" | coresdk.child_workflow.ParentClosePolicy | null | undefined) => coresdk.child_workflow.ParentClosePolicy | undefined, decodeParentClosePolicy: (input: coresdk.child_workflow.ParentClosePolicy | null | undefined) => "ABANDON" | "TERMINATE" | "REQUEST_CANCEL" | undefined;
|
|
352
389
|
export interface ChildWorkflowOptions extends Omit<CommonWorkflowOptions, 'workflowIdConflictPolicy'> {
|
|
353
390
|
/**
|
|
@@ -364,18 +401,24 @@ export interface ChildWorkflowOptions extends Omit<CommonWorkflowOptions, 'workf
|
|
|
364
401
|
*/
|
|
365
402
|
taskQueue?: string;
|
|
366
403
|
/**
|
|
367
|
-
*
|
|
368
|
-
* - whether cancellation requests
|
|
369
|
-
* - whether and when
|
|
370
|
-
* {@link ChildWorkflowHandle.result}
|
|
404
|
+
* Determines:
|
|
405
|
+
* - whether cancellation requests should be propagated from the Parent Workflow to the Child, and
|
|
406
|
+
* - whether and when should the Child's cancellation be reported back to the Parent Workflow
|
|
407
|
+
* (i.e. at which moment should the {@link executeChild}'s or {@link ChildWorkflowHandle.result}'s
|
|
408
|
+
* promise fail with a `ChildWorkflowFailure`, with `cause` set to a `CancelledFailure`).
|
|
409
|
+
*
|
|
410
|
+
* Note that this setting only applies to cancellation originating from an external request for the
|
|
411
|
+
* Parent Workflow itself, or from internal cancellation of the `CancellationScope` in which the
|
|
412
|
+
* Child Workflow call was made. Eventual Cancellation of a Child Workflow on completion of the
|
|
413
|
+
* Parent Workflow is controlled by the {@link ParentClosePolicy} setting.
|
|
371
414
|
*
|
|
372
|
-
* @default
|
|
415
|
+
* @default ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED
|
|
373
416
|
*/
|
|
374
417
|
cancellationType?: ChildWorkflowCancellationType;
|
|
375
418
|
/**
|
|
376
419
|
* Specifies how the Child reacts to the Parent Workflow reaching a Closed state.
|
|
377
420
|
*
|
|
378
|
-
* @default
|
|
421
|
+
* @default ParentClosePolicy.PARENT_CLOSE_POLICY_TERMINATE
|
|
379
422
|
*/
|
|
380
423
|
parentClosePolicy?: ParentClosePolicy;
|
|
381
424
|
/**
|
|
@@ -384,8 +427,7 @@ export interface ChildWorkflowOptions extends Omit<CommonWorkflowOptions, 'workf
|
|
|
384
427
|
*
|
|
385
428
|
* @default 'COMPATIBLE'
|
|
386
429
|
*
|
|
387
|
-
* @deprecated
|
|
388
|
-
* @experimental The Worker Versioning API is still being designed. Major changes are expected.
|
|
430
|
+
* @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
|
|
389
431
|
*/
|
|
390
432
|
versioningIntent?: VersioningIntent;
|
|
391
433
|
}
|
|
@@ -463,6 +505,7 @@ export interface WorkflowCreateOptionsInternal extends WorkflowCreateOptions {
|
|
|
463
505
|
sourceMap: RawSourceMap;
|
|
464
506
|
registeredActivityNames: Set<string>;
|
|
465
507
|
getTimeOfDay(): bigint;
|
|
508
|
+
stackTracesEnabled: boolean;
|
|
466
509
|
}
|
|
467
510
|
/**
|
|
468
511
|
* A handler function capable of accepting the arguments for a given UpdateDefinition, SignalDefinition or QueryDefinition.
|
package/lib/interfaces.js
CHANGED
|
@@ -24,28 +24,63 @@ exports.ContinueAsNew = ContinueAsNew;
|
|
|
24
24
|
exports.ContinueAsNew = ContinueAsNew = __decorate([
|
|
25
25
|
(0, type_helpers_1.SymbolBasedInstanceOfError)('ContinueAsNew')
|
|
26
26
|
], ContinueAsNew);
|
|
27
|
+
/**
|
|
28
|
+
* Determines:
|
|
29
|
+
* - whether cancellation requests should be propagated from the Parent Workflow to the Child, and
|
|
30
|
+
* - whether and when should the Child's cancellation be reported back to the Parent Workflow
|
|
31
|
+
* (i.e. at which moment should the {@link executeChild}'s or {@link ChildWorkflowHandle.result}'s
|
|
32
|
+
* promise fail with a `ChildWorkflowFailure`, with `cause` set to a `CancelledFailure`).
|
|
33
|
+
*
|
|
34
|
+
* Note that this setting only applies to cancellation originating from an external request for the
|
|
35
|
+
* Parent Workflow itself, or from internal cancellation of the `CancellationScope` in which the
|
|
36
|
+
* Child Workflow call was made. Eventual Cancellation of a Child Workflow on completion of the
|
|
37
|
+
* Parent Workflow is controlled by the {@link ParentClosePolicy} setting.
|
|
38
|
+
*
|
|
39
|
+
* @default ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED
|
|
40
|
+
*/
|
|
41
|
+
// MAINTENANCE: Keep this typedoc in sync with the `ChildWorkflowOptions.cancellationType` field
|
|
27
42
|
exports.ChildWorkflowCancellationType = {
|
|
28
43
|
/**
|
|
29
|
-
*
|
|
44
|
+
* Do not propagate cancellation requests to the Child, and immediately report cancellation
|
|
45
|
+
* to the caller.
|
|
30
46
|
*/
|
|
31
47
|
ABANDON: 'ABANDON',
|
|
32
48
|
/**
|
|
33
|
-
*
|
|
49
|
+
* Propagate cancellation request from the Parent Workflow to the Child, yet _immediately_ report
|
|
50
|
+
* cancellation to the caller, i.e. without waiting for the server to confirm the cancellation
|
|
51
|
+
* request.
|
|
52
|
+
*
|
|
53
|
+
* Note that this cancellation type provides no guarantee, from the Parent-side, that the
|
|
54
|
+
* cancellation request will actually be atomically added to the Child workflow's history.
|
|
55
|
+
* In particular, the Child may complete (either successfully or uncessfully) before the
|
|
56
|
+
* cancellation is delivered, resulting in a situation where the Parent workflow thinks its child
|
|
57
|
+
* was cancelled, but the child actually completed successfully.
|
|
58
|
+
*
|
|
59
|
+
* To guarantee that the Child will eventually be notified of the cancellation request,
|
|
60
|
+
* use {@link WAIT_CANCELLATION_REQUESTED}.
|
|
34
61
|
*/
|
|
35
62
|
TRY_CANCEL: 'TRY_CANCEL',
|
|
36
63
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* ignore the cancellation request, in which case an error might be thrown with a different cause, or the Child may
|
|
40
|
-
* complete successfully.
|
|
64
|
+
* Propagate cancellation request from the Parent Workflow to the Child, then wait for the server
|
|
65
|
+
* to confirm that the Child Workflow cancellation request was recorded in its history.
|
|
41
66
|
*
|
|
42
|
-
*
|
|
67
|
+
* This cancellation type guarantees that the Child will eventually be notified of the
|
|
68
|
+
* cancellation request (that is, unless the Child terminates inbetween due to unexpected causes).
|
|
43
69
|
*/
|
|
44
|
-
|
|
70
|
+
WAIT_CANCELLATION_REQUESTED: 'WAIT_CANCELLATION_REQUESTED',
|
|
45
71
|
/**
|
|
46
|
-
*
|
|
72
|
+
* Propagate cancellation request from the Parent Workflow to the Child, then wait for completion
|
|
73
|
+
* of the Child Workflow.
|
|
74
|
+
*
|
|
75
|
+
* The Child may respect cancellation, in which case the Parent's `executeChild` or
|
|
76
|
+
* `ChildWorkflowHandle.result` promise will fail with a `ChildWorkflowFailure`, with `cause`
|
|
77
|
+
* set to a `CancelledFailure`. On the other hand, the Child may ignore the cancellation request,
|
|
78
|
+
* in which case the corresponding promise will either resolve with a result (if Child completed
|
|
79
|
+
* successfully) or reject with a different cause (if Child completed uncessfully).
|
|
80
|
+
*
|
|
81
|
+
* @default
|
|
47
82
|
*/
|
|
48
|
-
|
|
83
|
+
WAIT_CANCELLATION_COMPLETED: 'WAIT_CANCELLATION_COMPLETED',
|
|
49
84
|
};
|
|
50
85
|
// ts-prune-ignore-next
|
|
51
86
|
_a = (0, enums_helpers_1.makeProtoEnumConverters)({
|
|
@@ -54,6 +89,11 @@ _a = (0, enums_helpers_1.makeProtoEnumConverters)({
|
|
|
54
89
|
[exports.ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED]: 2,
|
|
55
90
|
[exports.ChildWorkflowCancellationType.WAIT_CANCELLATION_REQUESTED]: 3,
|
|
56
91
|
}, ''), exports.encodeChildWorkflowCancellationType = _a[0], exports.decodeChildWorkflowCancellationType = _a[1];
|
|
92
|
+
/**
|
|
93
|
+
* How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy}
|
|
96
|
+
*/
|
|
57
97
|
exports.ParentClosePolicy = {
|
|
58
98
|
/**
|
|
59
99
|
* When the Parent is Closed, the Child is Terminated.
|
|
@@ -75,25 +115,25 @@ exports.ParentClosePolicy = {
|
|
|
75
115
|
*
|
|
76
116
|
* @deprecated Either leave property `undefined`, or set an explicit policy instead.
|
|
77
117
|
*/
|
|
78
|
-
PARENT_CLOSE_POLICY_UNSPECIFIED: undefined,
|
|
118
|
+
PARENT_CLOSE_POLICY_UNSPECIFIED: undefined,
|
|
79
119
|
/**
|
|
80
120
|
* When the Parent is Closed, the Child is Terminated.
|
|
81
121
|
*
|
|
82
122
|
* @deprecated Use {@link ParentClosePolicy.TERMINATE} instead.
|
|
83
123
|
*/
|
|
84
|
-
PARENT_CLOSE_POLICY_TERMINATE: 'TERMINATE',
|
|
124
|
+
PARENT_CLOSE_POLICY_TERMINATE: 'TERMINATE',
|
|
85
125
|
/**
|
|
86
126
|
* When the Parent is Closed, nothing is done to the Child.
|
|
87
127
|
*
|
|
88
128
|
* @deprecated Use {@link ParentClosePolicy.ABANDON} instead.
|
|
89
129
|
*/
|
|
90
|
-
PARENT_CLOSE_POLICY_ABANDON: 'ABANDON',
|
|
130
|
+
PARENT_CLOSE_POLICY_ABANDON: 'ABANDON',
|
|
91
131
|
/**
|
|
92
132
|
* When the Parent is Closed, the Child is Cancelled.
|
|
93
133
|
*
|
|
94
134
|
* @deprecated Use {@link ParentClosePolicy.REQUEST_CANCEL} instead.
|
|
95
135
|
*/
|
|
96
|
-
PARENT_CLOSE_POLICY_REQUEST_CANCEL: 'REQUEST_CANCEL',
|
|
136
|
+
PARENT_CLOSE_POLICY_REQUEST_CANCEL: 'REQUEST_CANCEL',
|
|
97
137
|
};
|
|
98
138
|
// ts-prune-ignore-next
|
|
99
139
|
_b = (0, enums_helpers_1.makeProtoEnumConverters)({
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;AAiBA,sEAAiF;AACjF,0FAAiG;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;;AAiBA,sEAAiF;AACjF,0FAAiG;AAqQjG;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,KAAK;IACV;IAA5B,YAA4B,OAAkE;QAC5F,KAAK,CAAC,2BAA2B,CAAC,CAAC;QADT,YAAO,GAAP,OAAO,CAA2D;IAE9F,CAAC;CACF,CAAA;AAJY,sCAAa;wBAAb,aAAa;IADzB,I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vB,EAda,+BAAuB,UAAE,+BAAuB,SAc5D"}
|
package/lib/internals.d.ts
CHANGED
|
@@ -243,7 +243,8 @@ export declare class Activator implements ActivationHandler {
|
|
|
243
243
|
versioningBehavior?: VersioningBehavior;
|
|
244
244
|
workflowDefinitionOptionsGetter?: () => WorkflowDefinitionOptions;
|
|
245
245
|
readonly workflowSandboxDestructors: (() => void)[];
|
|
246
|
-
|
|
246
|
+
protected readonly stackTracesEnabled: boolean;
|
|
247
|
+
constructor({ info, now, showStackTraceSources, sourceMap, getTimeOfDay, randomnessSeed, registeredActivityNames, stackTracesEnabled, }: WorkflowCreateOptionsInternal);
|
|
247
248
|
/**
|
|
248
249
|
* May be invoked from outside the VM.
|
|
249
250
|
*/
|
package/lib/internals.js
CHANGED
|
@@ -307,7 +307,8 @@ class Activator {
|
|
|
307
307
|
versioningBehavior;
|
|
308
308
|
workflowDefinitionOptionsGetter;
|
|
309
309
|
workflowSandboxDestructors = [];
|
|
310
|
-
|
|
310
|
+
stackTracesEnabled;
|
|
311
|
+
constructor({ info, now, showStackTraceSources, sourceMap, getTimeOfDay, randomnessSeed, registeredActivityNames, stackTracesEnabled, }) {
|
|
311
312
|
this.getTimeOfDay = getTimeOfDay;
|
|
312
313
|
this.info = info;
|
|
313
314
|
this.now = now;
|
|
@@ -315,6 +316,7 @@ class Activator {
|
|
|
315
316
|
this.sourceMap = sourceMap;
|
|
316
317
|
this.random = (0, alea_1.alea)(randomnessSeed);
|
|
317
318
|
this.registeredActivityNames = registeredActivityNames;
|
|
319
|
+
this.stackTracesEnabled = stackTracesEnabled;
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
320
322
|
* May be invoked from outside the VM.
|
|
@@ -323,6 +325,9 @@ class Activator {
|
|
|
323
325
|
this.info = fn(this.info);
|
|
324
326
|
}
|
|
325
327
|
getStackTraces() {
|
|
328
|
+
if (!this.stackTracesEnabled) {
|
|
329
|
+
throw new common_1.IllegalStateError('Workflow stack traces are not enabled on this worker');
|
|
330
|
+
}
|
|
326
331
|
const { childToParent, promiseToStack } = this.promiseStackStore;
|
|
327
332
|
const internalNodes = [...childToParent.values()].reduce((acc, curr) => {
|
|
328
333
|
for (const p of curr) {
|
|
@@ -656,8 +661,23 @@ class Activator {
|
|
|
656
661
|
let input;
|
|
657
662
|
try {
|
|
658
663
|
if (runValidator && entry.validator) {
|
|
659
|
-
|
|
660
|
-
|
|
664
|
+
// Temporarily mark as not replaying history events during validator execution
|
|
665
|
+
// so that logging is permitted. Validators are live read-only operations.
|
|
666
|
+
const wasReplayingHistoryEvents = this.info.unsafe.isReplayingHistoryEvents;
|
|
667
|
+
this.mutateWorkflowInfo((info) => ({
|
|
668
|
+
...info,
|
|
669
|
+
unsafe: { ...info.unsafe, isReplayingHistoryEvents: false },
|
|
670
|
+
}));
|
|
671
|
+
try {
|
|
672
|
+
const validate = (0, interceptors_1.composeInterceptors)(interceptors, 'validateUpdate', this.validateUpdateNextHandler.bind(this, entry.validator));
|
|
673
|
+
validate(makeInput());
|
|
674
|
+
}
|
|
675
|
+
finally {
|
|
676
|
+
this.mutateWorkflowInfo((info) => ({
|
|
677
|
+
...info,
|
|
678
|
+
unsafe: { ...info.unsafe, isReplayingHistoryEvents: wasReplayingHistoryEvents },
|
|
679
|
+
}));
|
|
680
|
+
}
|
|
661
681
|
}
|
|
662
682
|
input = makeInput();
|
|
663
683
|
}
|
|
@@ -718,9 +738,7 @@ class Activator {
|
|
|
718
738
|
while (this.bufferedUpdates.length) {
|
|
719
739
|
const update = this.bufferedUpdates.shift();
|
|
720
740
|
if (update) {
|
|
721
|
-
this.rejectUpdate(
|
|
722
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
723
|
-
update.protocolInstanceId, common_1.ApplicationFailure.nonRetryable(`No registered handler for update: ${update.name}`));
|
|
741
|
+
this.rejectUpdate(update.protocolInstanceId, common_1.ApplicationFailure.nonRetryable(`No registered handler for update: ${update.name}`));
|
|
724
742
|
}
|
|
725
743
|
}
|
|
726
744
|
}
|
|
@@ -774,7 +792,6 @@ class Activator {
|
|
|
774
792
|
while (bufferedSignals.length) {
|
|
775
793
|
if (this.defaultSignalHandler) {
|
|
776
794
|
// We have a default signal handler, so all signals are dispatchable
|
|
777
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
778
795
|
this.signalWorkflow(bufferedSignals.shift());
|
|
779
796
|
}
|
|
780
797
|
else {
|