Skip to content

Commit 15b1503

Browse files
committed
nits
1 parent 7e9971a commit 15b1503

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

packages/workflow/src/interfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ export type DefaultSignalHandler = (signalName: string, ...args: unknown[]) => v
541541
/**
542542
* A handler function accepting update calls for non-registered update names.
543543
*/
544-
export type DefaultUpdateHandler = (updateName: string, ...args: any[]) => Promise<any> | any;
544+
export type DefaultUpdateHandler = (updateName: string, ...args: unknown[]) => Promise<unknown> | unknown;
545545

546546
/**
547547
* A validation function capable of accepting the arguments for a given UpdateDefinition.

packages/workflow/src/internals.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -671,21 +671,24 @@ export class Activator implements ActivationHandler {
671671
if (!protocolInstanceId) {
672672
throw new TypeError('Missing activation update protocolInstanceId');
673673
}
674-
if (!this.updateHandlers.get(name) && !this.defaultUpdateHandler) {
674+
675+
const entry =
676+
this.updateHandlers.get(name) ??
677+
(this.defaultUpdateHandler
678+
? {
679+
handler: this.defaultUpdateHandler.bind(name),
680+
validator: undefined,
681+
// Default to a warning policy.
682+
unfinishedPolicy: HandlerUnfinishedPolicy.WARN_AND_ABANDON,
683+
}
684+
: null);
685+
686+
// If we don't have an entry from either source, buffer and return
687+
if (entry === null) {
675688
this.bufferedUpdates.push(activation);
676689
return;
677690
}
678691

679-
const entry = this.updateHandlers.get(name) ?? {
680-
// Logically, this must be defined as we got passed the conditional above
681-
// pushing to the buffer. But Typescript doesn't know that so we use a
682-
// non-null assertion (!).
683-
handler: (...args: any[]) => this.defaultUpdateHandler!(name, ...args),
684-
validator: undefined,
685-
// Default to a warning policy.
686-
unfinishedPolicy: HandlerUnfinishedPolicy.WARN_AND_ABANDON,
687-
};
688-
689692
const makeInput = (): UpdateInput => ({
690693
updateId,
691694
args: arrayFromPayloads(this.payloadConverter, activation.input),

0 commit comments

Comments
 (0)