chore: idempotent cart operations (#13236)
* chore(core-flows): idempotent cart operations * changeset * add tests * revert * revert route * promo test * skip bugs * fix test * tests * avoid workflow name conflict * prevent nested workflow from being deleted until the top level parent finishes * remove unused setTimeout * update changeset * rm comments --------- Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
This commit is contained in:
committed by
GitHub
parent
b111d01898
commit
9412669e65
@@ -138,8 +138,6 @@ export class InMemoryDistributedTransactionStorage
|
||||
private async deleteFromDb(data: TransactionCheckpoint) {
|
||||
await this.workflowExecutionService_.delete([
|
||||
{
|
||||
workflow_id: data.flow.modelId,
|
||||
transaction_id: data.flow.transactionId,
|
||||
run_id: data.flow.runId,
|
||||
},
|
||||
])
|
||||
@@ -223,7 +221,7 @@ export class InMemoryDistributedTransactionStorage
|
||||
TransactionState.REVERTED,
|
||||
].includes(data.flow.state)
|
||||
|
||||
const { retentionTime, idempotent } = options ?? {}
|
||||
const { retentionTime } = options ?? {}
|
||||
|
||||
await this.#preventRaceConditionExecutionIfNecessary({
|
||||
data,
|
||||
@@ -261,8 +259,13 @@ export class InMemoryDistributedTransactionStorage
|
||||
|
||||
// Optimize DB operations - only perform when necessary
|
||||
if (hasFinished) {
|
||||
if (!retentionTime && !idempotent) {
|
||||
await this.deleteFromDb(data)
|
||||
if (!retentionTime) {
|
||||
// If the workflow is nested, we cant just remove it because it would break the compensation algorithm. Instead, it will get deleted when the top level parent is deleted.
|
||||
if (!flow.metadata?.parentStepIdempotencyKey) {
|
||||
await this.deleteFromDb(data)
|
||||
} else {
|
||||
await this.saveToDb(data, retentionTime)
|
||||
}
|
||||
} else {
|
||||
await this.saveToDb(data, retentionTime)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user