fix(): temporary transform cached data (#13467)
**What** Properly store key obj reference for weak map usage
This commit is contained in:
committed by
GitHub
parent
0700a2448c
commit
0079464f32
6
.changeset/ninety-years-float.md
Normal file
6
.changeset/ninety-years-float.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/orchestration": patch
|
||||
"@medusajs/workflows-sdk": patch
|
||||
---
|
||||
|
||||
fix(): temporary transform cached data
|
||||
@@ -311,16 +311,16 @@ class DistributedTransaction extends EventEmitter {
|
||||
await DistributedTransaction.keyValueStore.clearStepTimeout(this, step)
|
||||
}
|
||||
|
||||
public setTemporaryData(key: string, value: unknown) {
|
||||
this.#temporaryStorage.set({ key }, value)
|
||||
public setTemporaryData(key: { key: string }, value: unknown) {
|
||||
this.#temporaryStorage.set(key, value)
|
||||
}
|
||||
|
||||
public getTemporaryData(key: string) {
|
||||
return this.#temporaryStorage.get({ key })
|
||||
public getTemporaryData(key: { key: string }) {
|
||||
return this.#temporaryStorage.get(key)
|
||||
}
|
||||
|
||||
public hasTemporaryData(key: string) {
|
||||
return this.#temporaryStorage.has({ key })
|
||||
public hasTemporaryData(key: { key: string }) {
|
||||
return this.#temporaryStorage.has(key)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -167,6 +167,7 @@ export function transform(
|
||||
const ret = {
|
||||
__id: uniqId,
|
||||
__type: OrchestrationUtils.SymbolWorkflowStepTransformer,
|
||||
__temporary_storage_key: null as { key: string } | null,
|
||||
}
|
||||
|
||||
const returnFn = async function (
|
||||
@@ -175,9 +176,16 @@ export function transform(
|
||||
): Promise<any> {
|
||||
if ("transaction" in transactionContext) {
|
||||
const temporaryDataKey = `${transactionContext.transaction.modelId}_${transactionContext.transaction.transactionId}_${uniqId}`
|
||||
ret.__temporary_storage_key ??= { key: temporaryDataKey }
|
||||
|
||||
if (transactionContext.transaction.hasTemporaryData(temporaryDataKey)) {
|
||||
return transactionContext.transaction.getTemporaryData(temporaryDataKey)
|
||||
if (
|
||||
transactionContext.transaction.hasTemporaryData(
|
||||
ret.__temporary_storage_key
|
||||
)
|
||||
) {
|
||||
return transactionContext.transaction.getTemporaryData(
|
||||
ret.__temporary_storage_key
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +203,10 @@ export function transform(
|
||||
}
|
||||
|
||||
if ("transaction" in transactionContext) {
|
||||
const temporaryDataKey = `${transactionContext.transaction.modelId}_${transactionContext.transaction.transactionId}_${uniqId}`
|
||||
const temporaryDataKey = ret.__temporary_storage_key!
|
||||
if (!temporaryDataKey) {
|
||||
return finalResult
|
||||
}
|
||||
|
||||
transactionContext.transaction.setTemporaryData(
|
||||
temporaryDataKey,
|
||||
|
||||
Reference in New Issue
Block a user