VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

TypeError: Cannot read property '_id' of undefined: Bug description and Fix #1669

Closed adalidda closed 5 years ago

adalidda commented 7 years ago

Hi,

I have 2 database (one in French and one in English). These 2 database work perfectly with VulcanJS version n-1. Now I am migrating my package for VulcanJS to VulcanJS 1.5.

I notice that my database in English work perfectly with my new package based on VulcanJS 1.5 while my database in French generate the following error: W20170711-17:56:31.316(7)? (STDERR) throw(ex); W20170711-17:56:31.317(7)? (STDERR) ^ W20170711-17:56:31.318(7)? (STDERR) W20170711-17:56:31.319(7)? (STDERR) TypeError: Cannot read property '_id' of undefined W20170711-17:56:31.321(7)? (STDERR) at createComment (packages/vulcan:getting-started/lib/server/seed.js:63:13) W20170711-17:56:31.322(7)? (STDERR) at createDummyComments (packages/vulcan:getting-started/lib/server/seed.js:119:3) W20170711-17:56:31.323(7)? (STDERR) at packages/vulcan:getting-started/lib/server/seed.js:147:5 W20170711-17:56:31.324(7)? (STDERR) at Function.time (/home/kauprey/Production-V4.0/.meteor/local/build/

So I identify that the package vulcan:getting-started generated this bug !

By removing this package with the command meteor remove vulcan:getting-started, my new package based on VulcanJS 1.5 work perfectly with my 2 database.

Hope this description help to fix the bug in the package vulcan:getting-started

Thank You Adalidda

mulikaminker commented 7 years ago

Thanks, but I get the response: Vulcan: getting-started is not directly dependent on this project And when I upload the app to the herooku I get an error

martinhbramwell commented 7 years ago

This issue needs higher priority, imho. It is very frustrating for newcomers to Vulcan.

There is a race condition where dummy users are created asynchronously and then called upon for creating other records, before their instantiation has to time to complete.

This little hack solves the problem ...

if (!Users.find().count()) {
  createDummyUsers();
}

while (  Users.find().count() < 3  ) {
  Meteor._sleepForMs(500);
};

if (!Pics.find().count()) {
  createDummyComments();
}

... , but a proper asynch solution would be better, and instructive for newbs.

eric-burel commented 5 years ago

Seems to have been fixed a while ago, closing for now