fix(): Transform map (#13655)

**What**
It seems that for some reason the weak map fail in some scenario, but after investigation, the usage of map would not have a bad impact as it will be released after the Distributed transaction if finished. Therefore, falling back to Map instead

FIXES https://github.com/medusajs/medusa/issues/13654

NOTE: Waiting for the user feedback as he is also using node 18. We also use the exact same pattern in all our core flows without issues 🤔
This commit is contained in:
Adrien de Peretti
2025-10-02 17:54:11 +02:00
committed by GitHub
parent ea3d0100a9
commit 8734866eb1
4 changed files with 30 additions and 17 deletions

View File

@@ -91,7 +91,7 @@ class DistributedTransaction extends EventEmitter {
*
* @private
*/
#temporaryStorage = new WeakMap<{ key: string }, unknown>()
#temporaryStorage = new Map<string, unknown>()
public static setStorage(storage: IDistributedTransactionStorage) {
this.keyValueStore = storage
@@ -311,15 +311,15 @@ class DistributedTransaction extends EventEmitter {
await DistributedTransaction.keyValueStore.clearStepTimeout(this, step)
}
public setTemporaryData(key: { key: string }, value: unknown) {
public setTemporaryData(key: string, value: unknown) {
this.#temporaryStorage.set(key, value)
}
public getTemporaryData(key: { key: string }) {
public getTemporaryData(key: string) {
return this.#temporaryStorage.get(key)
}
public hasTemporaryData(key: { key: string }) {
public hasTemporaryData(key: string) {
return this.#temporaryStorage.has(key)
}