fix(wfe): should notify when finished + add state info (#12982)
This commit is contained in:
committed by
GitHub
parent
89a57edb30
commit
238e7d53c1
@@ -51,6 +51,7 @@ type NotifyOptions = {
|
||||
eventType: keyof DistributedTransactionEvents
|
||||
workflowId: string
|
||||
transactionId?: string
|
||||
state?: TransactionState
|
||||
step?: TransactionStep
|
||||
response?: unknown
|
||||
result?: unknown
|
||||
@@ -269,9 +270,6 @@ export class WorkflowOrchestratorService {
|
||||
throw new Error(`Workflow with id "${workflowId}" not found.`)
|
||||
}
|
||||
|
||||
const originalOnFinishHandler = events.onFinish!
|
||||
delete events.onFinish
|
||||
|
||||
const transaction = await this.getRunningTransaction(
|
||||
workflowId,
|
||||
transactionId,
|
||||
@@ -307,12 +305,11 @@ export class WorkflowOrchestratorService {
|
||||
const metadata = ret.transaction.getFlow().metadata
|
||||
const { parentStepIdempotencyKey } = metadata ?? {}
|
||||
|
||||
const hasFailed = [TransactionState.FAILED].includes(
|
||||
ret.transaction.getFlow().state
|
||||
)
|
||||
const transactionState = ret.transaction.getFlow().state
|
||||
const hasFailed = [TransactionState.FAILED].includes(transactionState)
|
||||
|
||||
const acknowledgement = {
|
||||
transactionId: context.transactionId,
|
||||
transactionId: transaction.transactionId,
|
||||
workflowId: workflowId,
|
||||
parentStepIdempotencyKey,
|
||||
hasFinished,
|
||||
@@ -323,8 +320,11 @@ export class WorkflowOrchestratorService {
|
||||
if (hasFinished) {
|
||||
const { result, errors } = ret
|
||||
|
||||
await originalOnFinishHandler({
|
||||
transaction: ret.transaction,
|
||||
this.notify({
|
||||
eventType: "onFinish",
|
||||
workflowId,
|
||||
transactionId: transaction.transactionId,
|
||||
state: transactionState as TransactionState,
|
||||
result,
|
||||
errors,
|
||||
})
|
||||
@@ -423,6 +423,7 @@ export class WorkflowOrchestratorService {
|
||||
eventType: "onFinish",
|
||||
workflowId,
|
||||
transactionId,
|
||||
state: ret.transaction.getFlow().state as TransactionState,
|
||||
result,
|
||||
errors,
|
||||
})
|
||||
@@ -493,6 +494,7 @@ export class WorkflowOrchestratorService {
|
||||
eventType: "onFinish",
|
||||
workflowId,
|
||||
transactionId,
|
||||
state: ret.transaction.getFlow().state as TransactionState,
|
||||
result,
|
||||
errors,
|
||||
})
|
||||
@@ -598,6 +600,7 @@ export class WorkflowOrchestratorService {
|
||||
result,
|
||||
step,
|
||||
response,
|
||||
state,
|
||||
} = options
|
||||
|
||||
const subscribers: TransactionSubscribers =
|
||||
@@ -613,6 +616,7 @@ export class WorkflowOrchestratorService {
|
||||
response,
|
||||
result,
|
||||
errors,
|
||||
state,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -641,12 +645,14 @@ export class WorkflowOrchestratorService {
|
||||
result,
|
||||
response,
|
||||
errors,
|
||||
state,
|
||||
}: {
|
||||
eventType: keyof DistributedTransactionEvents
|
||||
step?: TransactionStep
|
||||
response?: unknown
|
||||
result?: unknown
|
||||
errors?: unknown[]
|
||||
state?: TransactionState
|
||||
}) => {
|
||||
this.notify({
|
||||
workflowId,
|
||||
@@ -656,6 +662,7 @@ export class WorkflowOrchestratorService {
|
||||
step,
|
||||
result,
|
||||
errors,
|
||||
state,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user