Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order Item media is not awaited before additional order item transformations #6535

Closed
tedraykov opened this issue Sep 26, 2022 · 0 comments · Fixed by #6536
Closed

Order Item media is not awaited before additional order item transformations #6535

tedraykov opened this issue Sep 26, 2022 · 0 comments · Fixed by #6536
Labels
bug For issues that describe a defect or regression in the released software needs triage For issues that are awaiting triage by the core development team

Comments

@tedraykov
Copy link
Collaborator

Issue Description

When querying an order from MOC, the resolver for the items in the order tries to evaluate the image URLs:

imageURLs: await imageURLs(context, item),

After that, the orders plugin calls all functions of type xformOrderItems to apply additional transformations to the order items.
None of the stock plugins actually modify those order items and the whole property resolves correctly.

A problem might arise when a custom plugin tries to mutate the order items because they are not awaited and instead of a list of order items, the orders plugin passes a Promise of the array.

Steps to Reproduce

  1. Create a plugin that registers a function of type xformOrderItems and tries to modify the passed property of order items
  2. Register the plugin
  3. Place an order following the regular workflow
  4. An error will be thrown that you cant access any of the array properties of the order items (because it's a promise, rather than an array)

Possible Solution

Await the initial order items before passing them to the xformOrderItems functions

@tedraykov tedraykov added bug For issues that describe a defect or regression in the released software needs triage For issues that are awaiting triage by the core development team labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For issues that describe a defect or regression in the released software needs triage For issues that are awaiting triage by the core development team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant