medusa
medusa copied to clipboard
createRemoteLinkStep does not perform any compensation!
Bug report
Describe the bug
createRemoteLinkStep does not perform any compensation!
System information
Medusa version (including plugins): v2.0.1 Node.js version: Database: Operating system: Browser (if relevant):
Steps to reproduce the behavior
parallelize(
createRemoteLinkStep(links).config({name: 'link-medusa-order-and-packing-order'}),
createPackingCollectionLines({orders, col_orders}),
createPackingCollectionVariants(variantsInput),
)
I have three parallel steps, and I specifically threw an error in the third one. My createPackingCollectionLines step compensates for the created data as expected, but the createRemoteLinkStep does not
Expected behavior
createRemoteLinkStep should dismiss the created links
I copied the code for this step locally, and somehow the createdLinks array is undefined within the compensation function, even though it was returned correctly at the end of the execution function.
Alright, I dug in further and created a fourth, special error step that throws an error after 3000 ms
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
const errorStep = createStep(
{name: 'error-step'},
async () => {
await sleep(3000)
throw new Error('TEST')
}
)
I added it to my parallelize block, and here’s what happened:
parallelize(
createRemoteLinkStep(links).config({name: 'link-medusa-order-and-packing-order'}),
createPackingCollectionLines({orders, col_orders}),
createPackingCollectionVariants(variantsInput),
errorStep()
)
createRemoteLinkStep compensation input is undefined
createPackingCollectionLines compensation input is ok, as expected
createPackingCollectionVariants compensation input is undefined as well
Something strange is happening with the compensation input when using parallelize.
Ok, guys. I finally find out what causes an issue
When I remove .config({name: 'link-medusa-order-and-packing-order'}), everything works as expected.
But you’re using config throughout your codebase.
Hey @noubase , thank you for the report, I ll try to find out the issue here
I found the issue and will open a pr in a short time 👍
Here is the fix, let me know if you can try the snapshot but from the tests it should be good now
Closing as it seems the bug was fixed already, please let us know if that's not the case