@temporalio/workflow 1.17.3 → 1.17.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/workflow",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Temporal.io SDK Workflow sub-package",
5
5
  "keywords": [
6
6
  "temporal",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "nexus-rpc": "^0.0.2",
30
- "@temporalio/common": "1.17.3",
31
- "@temporalio/proto": "1.17.3"
30
+ "@temporalio/common": "1.17.5",
31
+ "@temporalio/proto": "1.17.5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "ava": "^5.3.1",
package/src/flags.ts CHANGED
@@ -114,7 +114,7 @@ type AltConditionFn = (ctx: { info: WorkflowInfo; sdkVersion?: string }) => bool
114
114
 
115
115
  function buildIdSdkVersionMatches(version: RegExp): AltConditionFn {
116
116
  const regex = new RegExp(`^@temporalio/worker@(${version.source})[+]`);
117
- return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId);
117
+ return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId); // eslint-disable-line @typescript-eslint/no-deprecated
118
118
  }
119
119
 
120
120
  type SemVer = {
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import { msToTs } from '@temporalio/common/lib/time';
7
7
  import { CancellationScope } from './cancellation-scope';
8
- import { currentRandom } from './current-random';
9
8
  import { DeterminismViolationError } from './errors';
10
9
  import { getActivator } from './global-attributes';
11
10
  import { SdkFlags } from './flags';
@@ -104,6 +103,6 @@ export function overrideGlobals(): void {
104
103
  }
105
104
  };
106
105
 
107
- // currentRandom() dispatches to a scoped stream when WorkflowRandomStream.with(...) is active.
108
- Math.random = currentRandom;
106
+ // activator.random is mutable, don't hardcode its reference
107
+ Math.random = () => getActivator().random();
109
108
  }
package/src/index.ts CHANGED
@@ -93,8 +93,8 @@ export {
93
93
  PayloadConverter,
94
94
  RetryPolicy,
95
95
  rootCause,
96
- SearchAttributes,
97
- SearchAttributeValue,
96
+ SearchAttributes, // eslint-disable-line @typescript-eslint/no-deprecated
97
+ SearchAttributeValue, // eslint-disable-line @typescript-eslint/no-deprecated
98
98
  ServerFailure,
99
99
  TemporalFailure,
100
100
  TerminatedFailure,
@@ -136,8 +136,6 @@ export {
136
136
  WorkflowInfo,
137
137
  } from './interfaces';
138
138
  export { proxySinks, Sink, SinkCall, SinkFunction, Sinks } from './sinks';
139
- export type { WorkflowRandomStream } from './random-streams';
140
- export { getRandomStream, workflowRandom } from './random-streams';
141
139
  export { log } from './logs';
142
140
  export { Trigger } from './trigger';
143
141
  export * from './workflow';
package/src/interfaces.ts CHANGED
@@ -47,7 +47,7 @@ export interface WorkflowInfo {
47
47
  * This value may change during the lifetime of an Execution.
48
48
  * @deprecated Use {@link typedSearchAttributes} instead.
49
49
  */
50
- readonly searchAttributes: SearchAttributes;
50
+ readonly searchAttributes: SearchAttributes; // eslint-disable-line @typescript-eslint/no-deprecated
51
51
 
52
52
  /**
53
53
  * Indexed information attached to the Workflow Execution, exposed through an interface.
@@ -337,7 +337,7 @@ export interface ContinueAsNewOptions {
337
337
  * Searchable attributes to attach to next Workflow run
338
338
  * @deprecated Use {@link typedSearchAttributes} instead.
339
339
  */
340
- searchAttributes?: SearchAttributes;
340
+ searchAttributes?: SearchAttributes; // eslint-disable-line @typescript-eslint/no-deprecated
341
341
  /**
342
342
  * Specifies additional indexed information to attach to the Workflow Execution. More info:
343
343
  * https://docs.temporal.io/docs/typescript/search-attributes
@@ -357,7 +357,7 @@ export interface ContinueAsNewOptions {
357
357
  *
358
358
  * @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
359
359
  */
360
- versioningIntent?: VersioningIntent;
360
+ versioningIntent?: VersioningIntent; // eslint-disable-line @typescript-eslint/no-deprecated
361
361
  /**
362
362
  * Defines the versioning behavior to be used by the first task of a new workflow run in a continue-as-new chain.
363
363
  *
@@ -567,7 +567,7 @@ export interface ChildWorkflowOptions extends Omit<CommonWorkflowOptions, 'workf
567
567
  *
568
568
  * @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
569
569
  */
570
- versioningIntent?: VersioningIntent;
570
+ versioningIntent?: VersioningIntent; // eslint-disable-line @typescript-eslint/no-deprecated
571
571
  }
572
572
 
573
573
  export type RequiredChildWorkflowOptions = Required<Pick<ChildWorkflowOptions, 'workflowId' | 'cancellationType'>> & {
@@ -646,7 +646,6 @@ export interface WorkflowCreateOptions {
646
646
  randomnessSeed: number[];
647
647
  now: number;
648
648
  showStackTraceSources: boolean;
649
- failureExceptionTypeNames?: string[];
650
649
  }
651
650
 
652
651
  export interface WorkflowCreateOptionsInternal extends WorkflowCreateOptions {
package/src/internals.ts CHANGED
@@ -1,20 +1,17 @@
1
- import type { AsyncLocalStorage as ALS } from 'node:async_hooks';
2
1
  import type { RawSourceMap } from 'source-map';
3
2
  import type {
4
- ActivitySerializationContext,
5
3
  FailureConverter,
6
4
  PayloadConverter,
7
- ProtoFailure,
8
5
  Workflow,
9
- WorkflowFunctionWithOptions,
10
6
  WorkflowQueryAnnotatedType,
11
7
  WorkflowSignalAnnotatedType,
12
8
  WorkflowUpdateAnnotatedType,
9
+ ProtoFailure,
13
10
  WorkflowUpdateType,
14
11
  WorkflowUpdateValidatorType,
12
+ WorkflowFunctionWithOptions,
15
13
  VersioningBehavior,
16
14
  WorkflowDefinitionOptions,
17
- WorkflowSerializationContext,
18
15
  } from '@temporalio/common';
19
16
  import {
20
17
  defaultFailureConverter,
@@ -34,6 +31,7 @@ import {
34
31
  decodeSearchAttributes,
35
32
  decodeTypedSearchAttributes,
36
33
  } from '@temporalio/common/lib/converter/payload-search-attributes';
34
+ import { composeInterceptors } from '@temporalio/common/lib/interceptors';
37
35
  import { makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
38
36
  import type { coresdk, temporal } from '@temporalio/proto';
39
37
  import {
@@ -44,9 +42,7 @@ import {
44
42
  import type { RNG } from './alea';
45
43
  import { alea } from './alea';
46
44
  import { RootCancellationScope } from './cancellation-scope';
47
- import { composeInterceptors } from './interceptor-composition';
48
- import { AsyncLocalStorage, UpdateScope } from './update-scope';
49
- import { deriveAleaSeed } from './random-stream-seed';
45
+ import { UpdateScope } from './update-scope';
50
46
  import { DeterminismViolationError, LocalActivityDoBackoff, isCancellation } from './errors';
51
47
  import type {
52
48
  QueryInput,
@@ -110,10 +106,9 @@ export interface PromiseStackStore {
110
106
  promiseToStack: Map<Promise<unknown>, Stack>;
111
107
  }
112
108
 
113
- export interface Completion<Success, Context = never> {
109
+ export interface Completion<Success> {
114
110
  resolve(val: Success): void;
115
111
  reject(reason: Error): void;
116
- context?: Context;
117
112
  }
118
113
 
119
114
  export interface Condition {
@@ -144,10 +139,6 @@ interface MessageHandlerExecution {
144
139
 
145
140
  type InferMapValue<T> = T extends Map<number, infer V> ? V : never;
146
141
 
147
- interface ScopedWorkflowRandomSource {
148
- random(): number;
149
- }
150
-
151
142
  /**
152
143
  * Keeps all of the Workflow runtime state like pending completions for activities and timers.
153
144
  *
@@ -177,13 +168,13 @@ export class Activator implements ActivationHandler {
177
168
  */
178
169
  readonly completions = {
179
170
  timer: new Map<number, Completion<void>>(),
180
- activity: new Map<number, Completion<unknown, ActivitySerializationContext>>(),
171
+ activity: new Map<number, Completion<unknown>>(),
181
172
  nexusOperationStart: new Map<number, Completion<StartNexusOperationOutput>>(),
182
173
  nexusOperationComplete: new Map<number, Completion<unknown>>(),
183
- childWorkflowStart: new Map<number, Completion<string, WorkflowSerializationContext>>(),
184
- childWorkflowComplete: new Map<number, Completion<unknown, WorkflowSerializationContext>>(),
185
- signalWorkflow: new Map<number, Completion<void, WorkflowSerializationContext>>(),
186
- cancelWorkflow: new Map<number, Completion<void, WorkflowSerializationContext>>(),
174
+ childWorkflowStart: new Map<number, Completion<string>>(),
175
+ childWorkflowComplete: new Map<number, Completion<unknown>>(),
176
+ signalWorkflow: new Map<number, Completion<void>>(),
177
+ cancelWorkflow: new Map<number, Completion<void>>(),
187
178
  };
188
179
 
189
180
  /**
@@ -277,22 +268,6 @@ export class Activator implements ActivationHandler {
277
268
  */
278
269
  public workflowTaskError: unknown;
279
270
 
280
- /**
281
- * Error type _names_ (from {@link WorkerOptions.workflowFailureErrorTypes}) that
282
- * should cause Workflow Execution failure rather than WFT failure.
283
- *
284
- * Set at workflow creation time from the worker options.
285
- */
286
- public failureExceptionTypeNames: string[] = [];
287
-
288
- /**
289
- * Error _types_ (from {@link WorkflowDefinitionOptions.failureExceptionTypes})
290
- * that should cause Workflow Execution failure rather than WFT failure.
291
- *
292
- * Set in `worker-interface.ts` after the workflow definition options are read.
293
- */
294
- public workflowDefinitionFailureExceptionTypes: Array<new (...args: any[]) => Error> | undefined = undefined;
295
-
296
271
  /**
297
272
  * Set to true when running synchronous code (e.g. while processing activation jobs and when calling
298
273
  * `tryUnblockConditions()`). While this flag is set, it is safe to let errors bubble up.
@@ -444,24 +419,10 @@ export class Activator implements ActivationHandler {
444
419
  public info: WorkflowInfo;
445
420
 
446
421
  /**
447
- * The main deterministic RNG for this workflow execution.
448
- *
449
- * Scoped overrides used by `WorkflowRandomStream.with(...)` are layered on top of this RNG.
422
+ * A deterministic RNG, used by the isolate's overridden Math.random
450
423
  */
451
424
  public random: RNG;
452
425
 
453
- /**
454
- * The current seed material for this workflow execution's deterministic RNGs.
455
- */
456
- public randomnessSeed: number[];
457
-
458
- /**
459
- * Additional deterministic RNG streams keyed by stable stream name.
460
- */
461
- public readonly namedRandomStreams = new Map<string, RNG>();
462
-
463
- protected currentRandomStorage?: ALS<ScopedWorkflowRandomSource | undefined>;
464
-
465
426
  public payloadConverter: PayloadConverter = defaultPayloadConverter;
466
427
  public failureConverter: FailureConverter = defaultFailureConverter;
467
428
 
@@ -511,55 +472,15 @@ export class Activator implements ActivationHandler {
511
472
  randomnessSeed,
512
473
  registeredActivityNames,
513
474
  stackTracesEnabled,
514
- failureExceptionTypeNames,
515
475
  }: WorkflowCreateOptionsInternal) {
516
476
  this.getTimeOfDay = getTimeOfDay;
517
477
  this.info = info;
518
478
  this.now = now;
519
479
  this.showStackTraceSources = showStackTraceSources;
520
480
  this.sourceMap = sourceMap;
521
- this.randomnessSeed = [...randomnessSeed];
522
- this.random = alea(this.randomnessSeed);
481
+ this.random = alea(randomnessSeed);
523
482
  this.registeredActivityNames = registeredActivityNames;
524
483
  this.stackTracesEnabled = stackTracesEnabled;
525
- this.failureExceptionTypeNames = failureExceptionTypeNames ?? [];
526
- }
527
-
528
- protected setRandomnessSeed(randomnessSeed: number[]): void {
529
- this.randomnessSeed = [...randomnessSeed];
530
- this.random = alea(this.randomnessSeed);
531
- this.namedRandomStreams.clear();
532
- }
533
-
534
- public getNamedRandom(name: string): RNG {
535
- const cached = this.namedRandomStreams.get(name);
536
- if (cached !== undefined) {
537
- return cached;
538
- }
539
-
540
- const random = alea(deriveAleaSeed(this.randomnessSeed, name));
541
- this.namedRandomStreams.set(name, random);
542
- return random;
543
- }
544
-
545
- protected withRandomSource<T>(randomSource: ScopedWorkflowRandomSource | undefined, fn: () => T): T {
546
- return (this.currentRandomStorage ??= new AsyncLocalStorage<ScopedWorkflowRandomSource | undefined>()).run(
547
- randomSource,
548
- fn
549
- );
550
- }
551
-
552
- public withCurrentRandom<T>(randomSource: ScopedWorkflowRandomSource, fn: () => T): T {
553
- return this.withRandomSource(randomSource, fn);
554
- }
555
-
556
- public bindCurrentRandom<T extends (...args: any[]) => any>(fn: T): T {
557
- const randomSource = this.currentRandomStorage?.getStore();
558
- return ((...args: Parameters<T>) => this.withRandomSource(randomSource, () => fn(...args))) as T;
559
- }
560
-
561
- public currentRandom(): number {
562
- return this.currentRandomStorage?.getStore()?.random() ?? this.random();
563
484
  }
564
485
 
565
486
  /**
@@ -633,13 +554,12 @@ export class Activator implements ActivationHandler {
633
554
 
634
555
  public startWorkflow(activation: coresdk.workflow_activation.IInitializeWorkflow): void {
635
556
  const execute = composeInterceptors(this.interceptors.inbound, 'execute', this.startWorkflowNextHandler.bind(this));
636
- const context = this.workflowSerializationContext();
637
557
 
638
558
  untrackPromise(
639
559
  executeWithLifecycleLogging(() =>
640
560
  execute({
641
561
  headers: activation.headers ?? {},
642
- args: arrayFromPayloads(this.payloadConverter, activation.arguments, context),
562
+ args: arrayFromPayloads(this.payloadConverter, activation.arguments),
643
563
  })
644
564
  ).then(this.completeWorkflow.bind(this), this.handleWorkflowFailure.bind(this))
645
565
  );
@@ -647,7 +567,6 @@ export class Activator implements ActivationHandler {
647
567
 
648
568
  public initializeWorkflow(activation: coresdk.workflow_activation.IInitializeWorkflow): void {
649
569
  const { continuedFailure, lastCompletionResult, memo, searchAttributes } = activation;
650
- const context = this.workflowSerializationContext();
651
570
 
652
571
  // Most things related to initialization have already been handled in the constructor
653
572
  this.mutateWorkflowInfo((info) => ({
@@ -656,17 +575,15 @@ export class Activator implements ActivationHandler {
656
575
  searchAttributes: decodeSearchAttributes(searchAttributes?.indexedFields),
657
576
  typedSearchAttributes: decodeTypedSearchAttributes(searchAttributes?.indexedFields),
658
577
 
659
- memo: mapFromPayloads(this.payloadConverter, memo?.fields, context),
660
- lastResult: fromPayloadsAtIndex(this.payloadConverter, 0, lastCompletionResult?.payloads, context),
578
+ memo: mapFromPayloads(this.payloadConverter, memo?.fields),
579
+ lastResult: fromPayloadsAtIndex(this.payloadConverter, 0, lastCompletionResult?.payloads),
661
580
  lastFailure:
662
581
  continuedFailure != null
663
- ? this.failureConverter.failureToError(continuedFailure, this.payloadConverter, context)
582
+ ? this.failureConverter.failureToError(continuedFailure, this.payloadConverter)
664
583
  : undefined,
665
584
  }));
666
- const workflowDefinitionOpts = this.workflowDefinitionOptionsGetter?.();
667
- if (workflowDefinitionOpts) {
668
- this.versioningBehavior = workflowDefinitionOpts.versioningBehavior;
669
- this.workflowDefinitionFailureExceptionTypes = workflowDefinitionOpts.failureExceptionTypes;
585
+ if (this.workflowDefinitionOptionsGetter) {
586
+ this.versioningBehavior = this.workflowDefinitionOptionsGetter().versioningBehavior;
670
587
  }
671
588
  }
672
589
 
@@ -686,23 +603,23 @@ export class Activator implements ActivationHandler {
686
603
  if (!activation.result) {
687
604
  throw new TypeError('Got ResolveActivity activation with no result');
688
605
  }
689
- const { resolve, reject, context } = this.consumeCompletion('activity', getSeq(activation));
606
+ const { resolve, reject } = this.consumeCompletion('activity', getSeq(activation));
690
607
  if (activation.result.completed) {
691
608
  const completed = activation.result.completed;
692
- const result = completed.result ? this.payloadConverter.fromPayload(completed.result, context) : undefined;
609
+ const result = completed.result ? this.payloadConverter.fromPayload(completed.result) : undefined;
693
610
  resolve(result);
694
611
  } else if (activation.result.failed) {
695
612
  const { failure } = activation.result.failed;
696
613
  if (failure == null) {
697
614
  throw new TypeError('Got failed result with no failure attribute');
698
615
  }
699
- reject(this.failureConverter.failureToError(failure, this.payloadConverter, context));
616
+ reject(this.failureToError(failure));
700
617
  } else if (activation.result.cancelled) {
701
618
  const { failure } = activation.result.cancelled;
702
619
  if (failure == null) {
703
620
  throw new TypeError('Got cancelled result with no failure attribute');
704
621
  }
705
- reject(this.failureConverter.failureToError(failure, this.payloadConverter, context));
622
+ reject(this.failureToError(failure));
706
623
  } else if (activation.result.backoff) {
707
624
  reject(new LocalActivityDoBackoff(activation.result.backoff));
708
625
  }
@@ -711,7 +628,7 @@ export class Activator implements ActivationHandler {
711
628
  public resolveChildWorkflowExecutionStart(
712
629
  activation: coresdk.workflow_activation.IResolveChildWorkflowExecutionStart
713
630
  ): void {
714
- const { resolve, reject, context } = this.consumeCompletion('childWorkflowStart', getSeq(activation));
631
+ const { resolve, reject } = this.consumeCompletion('childWorkflowStart', getSeq(activation));
715
632
  if (activation.succeeded) {
716
633
  if (!activation.succeeded.runId) {
717
634
  throw new TypeError('Got ResolveChildWorkflowExecutionStart with no runId');
@@ -735,7 +652,7 @@ export class Activator implements ActivationHandler {
735
652
  if (!activation.cancelled.failure) {
736
653
  throw new TypeError('Got no failure in cancelled variant');
737
654
  }
738
- reject(this.failureConverter.failureToError(activation.cancelled.failure, this.payloadConverter, context));
655
+ reject(this.failureToError(activation.cancelled.failure));
739
656
  } else {
740
657
  throw new TypeError('Got ResolveChildWorkflowExecutionStart with no status');
741
658
  }
@@ -745,23 +662,23 @@ export class Activator implements ActivationHandler {
745
662
  if (!activation.result) {
746
663
  throw new TypeError('Got ResolveChildWorkflowExecution activation with no result');
747
664
  }
748
- const { resolve, reject, context } = this.consumeCompletion('childWorkflowComplete', getSeq(activation));
665
+ const { resolve, reject } = this.consumeCompletion('childWorkflowComplete', getSeq(activation));
749
666
  if (activation.result.completed) {
750
667
  const completed = activation.result.completed;
751
- const result = completed.result ? this.payloadConverter.fromPayload(completed.result, context) : undefined;
668
+ const result = completed.result ? this.payloadConverter.fromPayload(completed.result) : undefined;
752
669
  resolve(result);
753
670
  } else if (activation.result.failed) {
754
671
  const { failure } = activation.result.failed;
755
672
  if (failure == null) {
756
673
  throw new TypeError('Got failed result with no failure attribute');
757
674
  }
758
- reject(this.failureConverter.failureToError(failure, this.payloadConverter, context));
675
+ reject(this.failureToError(failure));
759
676
  } else if (activation.result.cancelled) {
760
677
  const { failure } = activation.result.cancelled;
761
678
  if (failure == null) {
762
679
  throw new TypeError('Got cancelled result with no failure attribute');
763
680
  }
764
- reject(this.failureConverter.failureToError(failure, this.payloadConverter, context));
681
+ reject(this.failureToError(failure));
765
682
  }
766
683
  }
767
684
 
@@ -787,10 +704,9 @@ export class Activator implements ActivationHandler {
787
704
 
788
705
  public resolveNexusOperation(activation: coresdk.workflow_activation.IResolveNexusOperation): void {
789
706
  const seq = getSeq(activation);
790
- const context = this.workflowSerializationContext();
791
707
 
792
708
  if (activation.result?.completed) {
793
- const result = this.payloadConverter.fromPayload(activation.result.completed, context);
709
+ const result = this.payloadConverter.fromPayload(activation.result.completed);
794
710
 
795
711
  // It is possible for ResolveNexusOperation to be received without a prior ResolveNexusOperationStart,
796
712
  // e.g. because the handler completed the Operation synchronously.
@@ -851,14 +767,8 @@ export class Activator implements ActivationHandler {
851
767
  throw new TypeError('Missing query activation attributes');
852
768
  }
853
769
 
854
- // Reject __temporal_-prefixed queries that would otherwise be routed to the
855
- // user's default handler. A specific registered handler (e.g. from a
856
- // contrib package) is allowed through.
857
- if (
858
- queryType.startsWith(TEMPORAL_RESERVED_PREFIX) &&
859
- !this.queryHandlers.has(queryType) &&
860
- this.defaultQueryHandler !== undefined
861
- ) {
770
+ // If query has __temporal_ prefix but no handler exists, throw error
771
+ if (queryType.startsWith(TEMPORAL_RESERVED_PREFIX) && !this.queryHandlers.has(queryType)) {
862
772
  throw new TypeError(`Cannot use query name: '${queryType}', with reserved prefix: '${TEMPORAL_RESERVED_PREFIX}'`);
863
773
  }
864
774
 
@@ -869,10 +779,9 @@ export class Activator implements ActivationHandler {
869
779
  queryType === ENHANCED_STACK_TRACE_QUERY_NAME;
870
780
  const interceptors = isInternalQuery ? [] : this.interceptors.inbound;
871
781
  const execute = composeInterceptors(interceptors, 'handleQuery', this.queryWorkflowNextHandler.bind(this));
872
- const context = this.workflowSerializationContext();
873
782
  execute({
874
783
  queryName: queryType,
875
- args: arrayFromPayloads(this.payloadConverter, activation.arguments, context),
784
+ args: arrayFromPayloads(this.payloadConverter, activation.arguments),
876
785
  queryId,
877
786
  headers: headers ?? {},
878
787
  }).then(
@@ -893,15 +802,8 @@ export class Activator implements ActivationHandler {
893
802
  throw new TypeError('Missing activation update protocolInstanceId');
894
803
  }
895
804
 
896
- // Reject __temporal_-prefixed updates that would otherwise be routed to the
897
- // user's default handler. A specific registered handler (e.g. from a
898
- // contrib package) is allowed through, and unregistered names without a
899
- // default handler fall through to the buffer-then-reject path below.
900
- if (
901
- name.startsWith(TEMPORAL_RESERVED_PREFIX) &&
902
- !this.updateHandlers.has(name) &&
903
- this.defaultUpdateHandler !== undefined
904
- ) {
805
+ // If update has __temporal_ prefix but no handler exists, throw error
806
+ if (name.startsWith(TEMPORAL_RESERVED_PREFIX) && !this.updateHandlers.get(name)) {
905
807
  throw new TypeError(`Cannot use update name: '${name}', with reserved prefix: '${TEMPORAL_RESERVED_PREFIX}'`);
906
808
  }
907
809
 
@@ -929,15 +831,12 @@ export class Activator implements ActivationHandler {
929
831
  return;
930
832
  }
931
833
 
932
- const makeInput = (): UpdateInput => {
933
- const context = this.workflowSerializationContext();
934
- return {
935
- updateId,
936
- args: arrayFromPayloads(this.payloadConverter, activation.input, context),
937
- name,
938
- headers: headers ?? {},
939
- };
940
- };
834
+ const makeInput = (): UpdateInput => ({
835
+ updateId,
836
+ args: arrayFromPayloads(this.payloadConverter, activation.input),
837
+ name,
838
+ headers: headers ?? {},
839
+ });
941
840
 
942
841
  // The implementation below is responsible for upholding, and constrained
943
842
  // by, the following contract:
@@ -1080,15 +979,8 @@ export class Activator implements ActivationHandler {
1080
979
  throw new TypeError('Missing activation signalName');
1081
980
  }
1082
981
 
1083
- // Reject __temporal_-prefixed signals that would otherwise be routed to the
1084
- // user's default handler. A specific registered handler (e.g. from a
1085
- // contrib package) is allowed through, and unregistered names without a
1086
- // default handler fall through to the buffer-then-reject path below.
1087
- if (
1088
- signalName.startsWith(TEMPORAL_RESERVED_PREFIX) &&
1089
- !this.signalHandlers.has(signalName) &&
1090
- this.defaultSignalHandler !== undefined
1091
- ) {
982
+ // If signal has __temporal_ prefix but no handler exists, throw error
983
+ if (signalName.startsWith(TEMPORAL_RESERVED_PREFIX) && !this.signalHandlers.has(signalName)) {
1092
984
  throw new TypeError(
1093
985
  `Cannot use signal name: '${signalName}', with reserved prefix: '${TEMPORAL_RESERVED_PREFIX}'`
1094
986
  );
@@ -1115,9 +1007,8 @@ export class Activator implements ActivationHandler {
1115
1007
  const signalExecutionNum = this.signalHandlerExecutionSeq++;
1116
1008
  this.inProgressSignals.set(signalExecutionNum, { name: signalName, unfinishedPolicy });
1117
1009
  const execute = composeInterceptors(interceptors, 'handleSignal', this.signalWorkflowNextHandler.bind(this));
1118
- const context = this.workflowSerializationContext();
1119
1010
  execute({
1120
- args: arrayFromPayloads(this.payloadConverter, activation.input, context),
1011
+ args: arrayFromPayloads(this.payloadConverter, activation.input),
1121
1012
  signalName,
1122
1013
  headers: headers ?? {},
1123
1014
  })
@@ -1142,9 +1033,9 @@ export class Activator implements ActivationHandler {
1142
1033
  }
1143
1034
 
1144
1035
  public resolveSignalExternalWorkflow(activation: coresdk.workflow_activation.IResolveSignalExternalWorkflow): void {
1145
- const { resolve, reject, context } = this.consumeCompletion('signalWorkflow', getSeq(activation));
1036
+ const { resolve, reject } = this.consumeCompletion('signalWorkflow', getSeq(activation));
1146
1037
  if (activation.failure) {
1147
- reject(this.failureConverter.failureToError(activation.failure, this.payloadConverter, context));
1038
+ reject(this.failureToError(activation.failure));
1148
1039
  } else {
1149
1040
  resolve(undefined);
1150
1041
  }
@@ -1153,9 +1044,9 @@ export class Activator implements ActivationHandler {
1153
1044
  public resolveRequestCancelExternalWorkflow(
1154
1045
  activation: coresdk.workflow_activation.IResolveRequestCancelExternalWorkflow
1155
1046
  ): void {
1156
- const { resolve, reject, context } = this.consumeCompletion('cancelWorkflow', getSeq(activation));
1047
+ const { resolve, reject } = this.consumeCompletion('cancelWorkflow', getSeq(activation));
1157
1048
  if (activation.failure) {
1158
- reject(this.failureConverter.failureToError(activation.failure, this.payloadConverter, context));
1049
+ reject(this.failureToError(activation.failure));
1159
1050
  } else {
1160
1051
  resolve(undefined);
1161
1052
  }
@@ -1185,7 +1076,7 @@ export class Activator implements ActivationHandler {
1185
1076
  if (!activation.randomnessSeed) {
1186
1077
  throw new TypeError('Expected activation with randomnessSeed attribute');
1187
1078
  }
1188
- this.setRandomnessSeed(activation.randomnessSeed.toBytes());
1079
+ this.random = alea(activation.randomnessSeed.toBytes());
1189
1080
  }
1190
1081
 
1191
1082
  public notifyHasPatch(activation: coresdk.workflow_activation.INotifyHasPatch): void {
@@ -1280,7 +1171,7 @@ export class Activator implements ActivationHandler {
1280
1171
  this.pushCommand({ cancelWorkflowExecution: {} }, true);
1281
1172
  } else if (error instanceof ContinueAsNew) {
1282
1173
  this.pushCommand({ continueAsNewWorkflowExecution: error.command }, true);
1283
- } else if (error instanceof TemporalFailure || this.isConfiguredFailureException(error)) {
1174
+ } else if (error instanceof TemporalFailure) {
1284
1175
  // Fail the workflow. We do not want to issue unfinishedHandlers warnings. To achieve that, we
1285
1176
  // mark all handlers as completed now.
1286
1177
  this.inProgressSignals.clear();
@@ -1288,7 +1179,7 @@ export class Activator implements ActivationHandler {
1288
1179
  this.pushCommand(
1289
1180
  {
1290
1181
  failWorkflowExecution: {
1291
- failure: this.errorToFailure(ensureTemporalFailure(error)),
1182
+ failure: this.errorToFailure(error),
1292
1183
  },
1293
1184
  },
1294
1185
  true
@@ -1298,42 +1189,6 @@ export class Activator implements ActivationHandler {
1298
1189
  }
1299
1190
  }
1300
1191
 
1301
- /**
1302
- * Returns true if the given error matches any of the configured failure exception types
1303
- * (from {@link WorkerOptions.workflowFailureErrorTypes} or
1304
- * {@link WorkflowDefinitionOptions.failureExceptionTypes}).
1305
- */
1306
- private isConfiguredFailureException(error: unknown): boolean {
1307
- // Check class references from WorkflowDefinitionOptions (instanceof-based, supports subclasses)
1308
- if (this.workflowDefinitionFailureExceptionTypes) {
1309
- // We guarantee that including Error in the list will catch _any_ error.
1310
- if (this.workflowDefinitionFailureExceptionTypes.includes(Error)) return true;
1311
-
1312
- for (const errorType of this.workflowDefinitionFailureExceptionTypes) {
1313
- if (error instanceof errorType) return true;
1314
- }
1315
- }
1316
-
1317
- // Check class name strings from WorkerOptions (prototype-chain-based)
1318
- if (this.failureExceptionTypeNames.length > 0) {
1319
- // We guarantee that including 'Error' in the list will catch _any_ error.
1320
- if (this.failureExceptionTypeNames.includes('Error')) return true;
1321
-
1322
- if (typeof error === 'object' && error !== null) {
1323
- let ctor = (error as any).constructor;
1324
- while (ctor != null && ctor !== Function.prototype) {
1325
- const name = (ctor as any).name as string | undefined;
1326
- if (name) {
1327
- if (this.failureExceptionTypeNames.includes(name)) return true;
1328
- }
1329
- ctor = Object.getPrototypeOf(ctor);
1330
- }
1331
- }
1332
- }
1333
-
1334
- return false;
1335
- }
1336
-
1337
1192
  recordWorkflowTaskError(error: unknown): void {
1338
1193
  // Only keep the first error that bubbles up; subsequent errors will be ignored.
1339
1194
  if (this.workflowTaskError === undefined) this.workflowTaskError = error;
@@ -1353,9 +1208,8 @@ export class Activator implements ActivationHandler {
1353
1208
  }
1354
1209
 
1355
1210
  private completeQuery(queryId: string, result: unknown): void {
1356
- const context = this.workflowSerializationContext();
1357
1211
  this.pushCommand({
1358
- respondToQuery: { queryId, succeeded: { response: this.payloadConverter.toPayload(result, context) } },
1212
+ respondToQuery: { queryId, succeeded: { response: this.payloadConverter.toPayload(result) } },
1359
1213
  });
1360
1214
  }
1361
1215
 
@@ -1373,9 +1227,8 @@ export class Activator implements ActivationHandler {
1373
1227
  }
1374
1228
 
1375
1229
  private completeUpdate(protocolInstanceId: string, result: unknown): void {
1376
- const context = this.workflowSerializationContext();
1377
1230
  this.pushCommand({
1378
- updateResponse: { protocolInstanceId, completed: this.payloadConverter.toPayload(result, context) },
1231
+ updateResponse: { protocolInstanceId, completed: this.payloadConverter.toPayload(result) },
1379
1232
  });
1380
1233
  }
1381
1234
 
@@ -1413,11 +1266,10 @@ export class Activator implements ActivationHandler {
1413
1266
  }
1414
1267
 
1415
1268
  private completeWorkflow(result: unknown): void {
1416
- const context = this.workflowSerializationContext();
1417
1269
  this.pushCommand(
1418
1270
  {
1419
1271
  completeWorkflowExecution: {
1420
- result: this.payloadConverter.toPayload(result, context),
1272
+ result: this.payloadConverter.toPayload(result),
1421
1273
  },
1422
1274
  },
1423
1275
  true
@@ -1425,21 +1277,11 @@ export class Activator implements ActivationHandler {
1425
1277
  }
1426
1278
 
1427
1279
  errorToFailure(err: unknown): ProtoFailure {
1428
- const context = this.workflowSerializationContext();
1429
- return this.failureConverter.errorToFailure(err, this.payloadConverter, context);
1280
+ return this.failureConverter.errorToFailure(err, this.payloadConverter);
1430
1281
  }
1431
1282
 
1432
1283
  failureToError(failure: ProtoFailure): Error {
1433
- const context = this.workflowSerializationContext();
1434
- return this.failureConverter.failureToError(failure, this.payloadConverter, context);
1435
- }
1436
-
1437
- private workflowSerializationContext(): WorkflowSerializationContext {
1438
- return {
1439
- type: 'workflow',
1440
- namespace: this.info.namespace,
1441
- workflowId: this.info.workflowId,
1442
- };
1284
+ return this.failureConverter.failureToError(failure, this.payloadConverter);
1443
1285
  }
1444
1286
  }
1445
1287