Skip to content

fix: adding new items to an order should not crash - #6

Open
johannes-vogel wants to merge 4 commits into
mainfrom
fix-new-items
Open

fix: adding new items to an order should not crash#6
johannes-vogel wants to merge 4 commits into
mainfrom
fix-new-items

Conversation

@johannes-vogel

Copy link
Copy Markdown

No description provided.

@vl-leon

vl-leon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@johannes-vogel Does this happen because the order is not valid and the order item references a product that does not exist?

@johannes-vogel

Copy link
Copy Markdown
Author

It's a new OrderItem that's added to an existing Order.

@vl-leon

vl-leon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

I am trying to identify the use case. The variable before is not initialized because the product referenced by this OrderItem does not exist, right?

@johannes-vogel

Copy link
Copy Markdown
Author

For not yet existing Order Items, the quantity of the before image is undefined. This leads to the orderChanged event being emitted with 12 - undefined (which is NaN).

The correct change is to default to zero instead of the early exit.

Comment thread srv/orders-service.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants