question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seeding database fails

See original GitHub issue

If I try to seed a database it fails. How to reproduce:

  • docker-compose down # make sure none of the related containers are running
  • docker system prune -a # remove all stopped containers, images and networks not in use
  • docker-compose run --rm freecodecamp npm install# install deps
  • docker-compose run --rm freecodecamp npm run only-once # seed

Of interest is that entities not found, db may not be properly seeded is ironic when you try to seed a db 😉

Related but not identical #17256 -which shows a timeout connecting to the db, while my setup connects to the db just fine (fcc:server db connected +0ms).

▶ docker-compose run --rm freecodecamp npm run only-once
Starting freecodecamp_mailhog_1 ... done
Starting freecodecamp_db_1      ... done

> freecodecamp@0.1.0 only-once /app
> npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'


> freecodecamp@0.1.0 prelint-js /app
> npm run ensure-env


> freecodecamp@0.1.0 ensure-env /app
> node ./config/ensure-env.js



rev-manifest present




pathMigration present


/****/
Seeding Database
/****/
Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see https://fb.me/react-create-class
Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs
  fcc:server db connected +0ms
/app/node_modules/loopback-connector-mongodb/node_modules/mongodb/lib/utils.js:123
    process.nextTick(function() { throw err; });
                                  ^

Error: Error: entities not found, db may not be properly seeded
    at AnonymousObserver._onError (/app/server/boot/home.js:18:21)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.error (/app/node_modules/rx/dist/rx.js:1836:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onError (/app/node_modules/rx/dist/rx.js:1772:14)
    at AnonymousObserver.o.onError (/app/node_modules/rx/dist/rx.js:1999:22)
    at AnonymousObserver.tryCatcher (/app/node_modules/rx/dist/rx.js:63:31)
    at AutoDetachObserverPrototype.error (/app/node_modules/rx/dist/rx.js:5891:52)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onError (/app/node_modules/rx/dist/rx.js:1772:14)
    at InnerObserver.error (/app/node_modules/rx/dist/rx.js:4530:14)
    at InnerObserver.Rx.internals.AbstractObserver.AbstractObserver.onError (/app/node_modules/rx/dist/rx.js:1772:14)
    at InnerObserver.o.onError (/app/node_modules/rx/dist/rx.js:1999:22)
    at InnerObserver.tryCatcher (/app/node_modules/rx/dist/rx.js:63:31)
    at AutoDetachObserverPrototype.error (/app/node_modules/rx/dist/rx.js:5891:52)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onError (/app/node_modules/rx/dist/rx.js:1772:14)
    at AutoDetachObserver.o.onError (/app/node_modules/rx/dist/rx.js:1999:22)
    at AutoDetachObserver.o.onError (/app/node_modules/rx/dist/rx.js:1999:22)
    at /app/node_modules/rx/dist/rx.js:1904:72
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! freecodecamp@0.1.0 only-once: `npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the freecodecamp@0.1.0 only-once script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-05-29T00_05_10_316Z-debug.log

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
ojongeriuscommented, May 31, 2018

A hacky workaround for the moment is:

Edit home.js and comment out line 12 until 24.

You can this manually or if you have patch installed you could do this automatically by creating a file named home.patch with the following contents:

--- server/boot/home.js.orig	2018-06-01 11:01:27.000000000 +1200
+++ server/boot/home.js	2018-06-01 11:01:39.000000000 +1200
@@ -9,6 +9,7 @@
   const { About } = app.models;
   const router = app.loopback.Router();
   let challengeCount = 0;
+  /*
   cachedMap(app.models)
     .do(({ entities: { challenge } }) => {
       challengeCount = Object.keys(challenge).length;
@@ -22,6 +23,7 @@
         done();
       }
     );
+  */

   function addDefaultImage(req, res, next) {
     if (!req.user || req.user.picture) {

And then run patch like so:

▶ patch -p0 < home.patch
patching file server/boot/home.js

However you changed home.js, your next step is to run the seeding by either:

  • Docker: docker-compose run --rm freecodecamp npm run only-once
  • Other: npm run only-once

When seeding is done, restore home.js by doing git checkout server/boot/home.js and start freeCodecamp as you normally would, ie:

  • Docker: docker-compose up
  • Other: npm start

Contributions for a permanent fix are welcome!

4reactions
Bounceycommented, May 29, 2018

Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. Now I know what is broken, thank you for your investigation @ptsurbeleu!!

The models are imported from the app during seed to destroy/create blocks and challenges. This has a side-effect of spinning up the server, which in its current state, requires challenge info whilst bootstrapping.

I will see about patching this today

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error (The seeding operation failed) when running Add ...
This cmdlet adds a copy of the mailbox database without invoking automatic seeding. In this example, a copy of mailbox database DB01 is...
Read more >
error when seeding data into a database in laravel 8
am getting this error when seeding data into my database. apparently the I have 2 models bookings and bookingstatus model.the bookingstatus ...
Read more >
Database seed error - Laracasts
Hi, this is the first time that I use Laravel 5 and I need your help. After I create the database with "migrate",...
Read more >
Fortify Seeding error - Micro Focus Community
Seeding failed : Unable to seed all init seed bundles." What version of SSC? 22.1; Database - which one and what version?
Read more >
Reseeding after 'Mailbox Database Copy Failed & Suspended'
During seeding, you might encounter an issue with the passive database and the seeding stops with the error “Mailbox Database Copy Failed or ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found