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

fix: do not emit afterCartUpdate unless surcharges are updated #5001

Merged
merged 2 commits into from
Feb 20, 2019

Conversation

aldeed
Copy link
Contributor

@aldeed aldeed commented Feb 20, 2019

Resolves #4995
Impact: minor
Type: bugfix

Issue

The afterCartUpdate handler for surcharges was emitting its own afterCartUpdate event even when it hadn't changed the surcharges list at all.

Solution

Check whether the surcharges list has changed before emitting.

Breaking changes

None

Testing

See reproduction steps in the linked issue

@aldeed aldeed self-assigned this Feb 20, 2019
@aldeed aldeed added this to the 🏔 Torreys milestone Feb 20, 2019
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I have no surcharges already applied to a cart (In this case, I never added any to the DB, therefore there were never any added to any order / cart), I get the following:

 Error in "afterCartUpdate" consumer TypeError: Cannot read property 'map' of undefined
      at Promise.asyncApply (imports/plugins/included/surcharges/server/no-meteor/startup.js:44:32)
      at /home/node/.meteor/packages/promise/.0.11.2.1gwulfb.vjny++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40
   => awaited here:
      at Function.Promise.await (/home/node/.meteor/packages/promise/.0.11.2.1gwulfb.vjny++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/promise_server.js:56:12)
      at Promise.asyncApply (imports/node-app/core/util/appEvents.js:24:5)
      at /home/node/.meteor/packages/promise/.0.11.2.1gwulfb.vjny++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40

Signed-off-by: Eric Dobbertin <[email protected]>
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good with the change. Do not see an infinite loop, nor the issue I mentioned in my previous comment.

@Akarshit Akarshit merged commit dd2bd24 into develop Feb 20, 2019
@aldeed aldeed deleted the fix-aldeed-4995-cart-update-loop branch February 25, 2019 21:46
@jeffcorpuz jeffcorpuz mentioned this pull request Mar 1, 2019
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.

3 participants