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

Cart cleanup job crashes on start #4786

Closed
brent-hoover opened this issue Nov 1, 2018 · 2 comments
Closed

Cart cleanup job crashes on start #4786

brent-hoover opened this issue Nov 1, 2018 · 2 comments
Labels
bug For issues that describe a defect or regression in the released software

Comments

@brent-hoover
Copy link
Collaborator

brent-hoover commented Nov 1, 2018

Issue Description

When the cart cleanup job (which removes all anonymous carts over X days) starts, it crashes with this error:

Exception in setTimeout callback: TypeError: moment is not a function
    at JobQueue.Jobs.processJobs [as worker] (imports/plugins/included/jobcontrol/server/jobs/cleanup.js:36:23)
    at JobQueue._process (/Users/brenthoover/Projects/js/reaction/node_modules/@reactioncommerce/job-queue/dist/common/jobFactory.js:432:23)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
    at packages/meteor.js:620:25
    at runWithEnvironment (packages/meteor.js:1356:24)

Steps to Reproduce

  1. In the Dashboard in Shops/Options set the cleanup duration to a very short period.
  2. Wait
  3. Observe the error

Possible Solution

With the way that carts are created now it may no longer be necessary to have this function but I am not sure.

This error probably has to do with someone trying to lazyload moment which is entirely not necessary on the server-side, which is where this code lives.

Versions

Reaction: 2.0.0-rc5

@brent-hoover brent-hoover added bug For issues that describe a defect or regression in the released software impact-minor labels Nov 1, 2018
@aldeed
Copy link
Contributor

aldeed commented Nov 2, 2018

@jeffcorpuz and I had looked at this error awhile back. Not sure if he created an issue for it at the time. I believe moment is being used for something easy and we could just not use moment at all. In 2.0 carts are deleted when they become orders or when you log in and they get merged into an account cart. But it seems like users would still want a cleanup job for eventually deleting abandoned carts, which is what I think this is for.

@hfmw
Copy link
Contributor

hfmw commented Nov 11, 2018

Not sure if this is a suitable approach for you now, but I refactored cartCleanupJob as it was designed initially and it works well for me: #4799

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
Projects
None yet
Development

No branches or pull requests

3 participants