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

Importer errors with Products causes app to crash with an uncaught error #4326

Closed
mikemurray opened this issue Jun 14, 2018 · 3 comments · Fixed by #4296
Closed

Importer errors with Products causes app to crash with an uncaught error #4326

mikemurray opened this issue Jun 14, 2018 · 3 comments · Fixed by #4296
Assignees
Labels
bug For issues that describe a defect or regression in the released software
Milestone

Comments

@mikemurray
Copy link
Member

mikemurray commented Jun 14, 2018

Issue Description

Don't import data into Products, Shipping, and Tags collection if data already exists. The importer sometimes freaks out and tries to re-import the same data into those collections with the same ID and it causes to the app to crash on startup.

(This error is from an added console log of the uncaught error in the importer)

reaction_1   | Error: WriteError({"code":11000,"index":0,"errmsg":"E11000 duplicate key error collection: reaction.Products index: _id_ dup key: { : \"BCTMZ6HTxFSppJESk\" }","op":{"q":{"title":"Basic Reaction Product","_id":"BCTMZ6HTxFSppJESk"},"u":{"$set":{"_id":"BCTMZ6HTxFSppJESk","shopId":"J8Bhq3uTtdgwZx3rz","ancestors":[],"description":"Sign in as administrator to edit.\nYou can clone this product from the product grid.\nYou can upload images click or drag in image box on the left here.\nTag this product below, and then add tag in navigation.\nClick the bookmark in the tag to set product url.\nOption variants, price, quantity, and child variants are created by clicking on the variant below, clone the variant to add more options.\nDetails can be added below the image for more specific product information.\n Login next to the cart, and then click the dashboard icon for more tools.","handle":"basic-reaction-product","hashtags":["rpjCvTBGjhBi2xdro","cseCBSSrJ3t8HQSNP"],"price.range":"12.99 - 19.99","price.min":12.99,"price.max":19.99,"isVisible":true,"isLowQuantity":false,"isSoldOut":false,"isBackorder":false,"metafields":[{"key":"Material","value":"Cotton"},{"key":"Quality","value":"Excellent"}],"pageTitle":"This is a basic product. You can do a lot with it.","type":"simple","title":"Basic Reaction Product","updatedAt":"2018-06-14T16:50:16.381Z","vendor":"Example Manufacturer"},"$setOnInsert":{"createdAt":"2018-06-14T16:50:16.380Z","requiresShipping":true,"isDeleted":false,"template":"productDetailSimple","workflow":{"status":"new"}}},"multi":true,"upsert":true}})
reaction_1   |     at buffer.execute (server/api/core/importer.js:130:26)
reaction_1   |     at err (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:415:14)
reaction_1   |     at session.endSession (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:399:27)
reaction_1   |     at ClientSession.endSession (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb-core/lib/sessions.js:72:41)
reaction_1   |     at executeCallback (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:397:17)
reaction_1   |     at handleCallback (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:128:55)
reaction_1   |     at /home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/bulk/unordered.js:528:20
reaction_1   |     at handleCallback (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:128:55)
reaction_1   |     at resultHandler (/home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/bulk/unordered.js:451:5)
reaction_1   |     at /home/node/.meteor/packages/npm-mongo/.3.0.7.g0jse4.0t1w++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb-core/lib/connection/pool.js:544:18
reaction_1   |     at _combinedTickCallback (internal/process/next_tick.js:131:7)
reaction_1   |     at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Steps to Reproduce

  1. With a fresh app go to the PDP page as an admin
  2. Change the product title. I did Basic Reaction Product--
  3. Restart the app either with a code change or, stop/start
  4. Observe the app not starting due to an error.

Possible Solution

  • count === 0 to wrap import statements in /server/startup/load-data.js
  • Guard against errors in /server/api/core/importer.js in Importer.commit

Versions

Node: 9.10.1
NPM: 6.1.0
Meteor Node: 8.11.2
Meteor NPM: 5.10.0
Reaction CLI: 0.29.0
Reaction: 1.13.0
Reaction branch: feat-4319-mikemurray-pdp-catalog
Docker: 18.03.1-ce

@mikemurray mikemurray added bug For issues that describe a defect or regression in the released software impact-critical labels Jun 14, 2018
@mikemurray mikemurray added this to the Grays milestone Jun 14, 2018
@mikemurray mikemurray self-assigned this Jun 14, 2018
@spencern
Copy link
Contributor

@mikemurray I think your proposed solution might be all we need here. Just a quick check to see if there is data in the app already.

@mikemurray
Copy link
Member Author

mikemurray commented Jun 14, 2018

@spencern so do or don't guard in the Importer?

    this.buffer(collection).execute((error, result) => {
      if (error) { // <-- added this becuase the callback always assumes theres no error
        Logger.error(error);
        return;
      }

@spencern
Copy link
Contributor

Closed by #4327

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

Successfully merging a pull request may close this issue.

2 participants