Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
THardy98 committed Mar 10, 2025
1 parent 7e9971a commit 15b1503
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/workflow/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export type DefaultSignalHandler = (signalName: string, ...args: unknown[]) => v
/**
* A handler function accepting update calls for non-registered update names.
*/
export type DefaultUpdateHandler = (updateName: string, ...args: any[]) => Promise<any> | any;
export type DefaultUpdateHandler = (updateName: string, ...args: unknown[]) => Promise<unknown> | unknown;

/**
* A validation function capable of accepting the arguments for a given UpdateDefinition.
Expand Down
25 changes: 14 additions & 11 deletions packages/workflow/src/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,21 +671,24 @@ export class Activator implements ActivationHandler {
if (!protocolInstanceId) {
throw new TypeError('Missing activation update protocolInstanceId');
}
if (!this.updateHandlers.get(name) && !this.defaultUpdateHandler) {

const entry =
this.updateHandlers.get(name) ??
(this.defaultUpdateHandler
? {
handler: this.defaultUpdateHandler.bind(name),
validator: undefined,
// Default to a warning policy.
unfinishedPolicy: HandlerUnfinishedPolicy.WARN_AND_ABANDON,
}
: null);

// If we don't have an entry from either source, buffer and return
if (entry === null) {
this.bufferedUpdates.push(activation);
return;
}

const entry = this.updateHandlers.get(name) ?? {
// Logically, this must be defined as we got passed the conditional above
// pushing to the buffer. But Typescript doesn't know that so we use a
// non-null assertion (!).
handler: (...args: any[]) => this.defaultUpdateHandler!(name, ...args),
validator: undefined,
// Default to a warning policy.
unfinishedPolicy: HandlerUnfinishedPolicy.WARN_AND_ABANDON,
};

const makeInput = (): UpdateInput => ({
updateId,
args: arrayFromPayloads(this.payloadConverter, activation.input),
Expand Down

0 comments on commit 15b1503

Please sign in to comment.