agenda-ui icon indicating copy to clipboard operation
agenda-ui copied to clipboard

Cannot read property 'count' of undefined

Open FLYBYME opened this issue 9 years ago • 21 comments

TypeError: Cannot read property 'count' of undefined
    at Store.count (/home/bob/files/node_modules/agenda-ui/lib/store.js:41:37)
    at Store.definitions (/home/bob/files/node_modules/agenda-ui/lib/store.js:69:26)
    at /home/bob/files/node_modules/agenda-ui/lib/api.js:13:11
    at Layer.handle [as handle_request] (/home/bob/files/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/bob/files/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/bob/files/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/bob/files/node_modules/express/lib/router/layer.js:95:5)
    at /home/bob/files/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/bob/files/node_modules/express/lib/router/index.js:330:12)
    at next (/home/bob/files/node_modules/express/lib/router/index.js:271:10)
    at Function.handle (/home/bob/files/node_modules/express/lib/router/index.js:176:3)
    at router (/home/bob/files/node_modules/express/lib/router/index.js:46:12)
    at Layer.handle [as handle_request] (/home/bob/files/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/bob/files/node_modules/express/lib/router/index.js:312:13)
    at /home/bob/files/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/home/bob/files/node_modules/express/lib/router/index.js:330:12)

``

FLYBYME avatar Nov 09 '15 17:11 FLYBYME

My guess is this is related to a (poor) choice to change the DB driver in agenda. Seems like it might be a bit painful to fix.

https://github.com/rschmukler/agenda/issues/213

wesley-harding avatar Nov 10 '15 06:11 wesley-harding

Do you have advice on what version of agenda should be used?

FLYBYME avatar Nov 10 '15 16:11 FLYBYME

You should be good with 0.6.8. You'll also need to use an older version of Mongo or mongoose (I can't remember which one off the top of my head) On Nov 10, 2015 11:40 AM, "Tim" [email protected] wrote:

Do you have advice on what version of agenda should be used?

— Reply to this email directly or view it on GitHub https://github.com/moudy/agenda-ui/issues/18#issuecomment-155481258.

wesley-harding avatar Nov 10 '15 16:11 wesley-harding

Also having this issue

b0bu avatar Nov 19 '15 21:11 b0bu

+1

jdnichollsc avatar Nov 20 '15 14:11 jdnichollsc

See more info please:

http://screencast.com/t/TgcnNQvu8D http://screencast.com/t/LhV6JnZnm http://screencast.com/t/33zQSdxgD2

jdnichollsc avatar Nov 20 '15 15:11 jdnichollsc

I have the same issue, and downgrading agenda to the older version doesn't work as well.

harelba avatar Nov 25 '15 10:11 harelba

agenda._db = agenda._collection; //add this line before passing agenda to agenda-ui app.use('/agenda/admin/jobs', agendaUI(agenda, {poll: 30000}));

pavan612 avatar Dec 03 '15 08:12 pavan612

@pavan612 thanks for trying to help. Tried it, but I'm still getting the error -

TypeError: Cannot read property 'count' of undefined
    at Store.count (/Users/harel/dev/trickly/src/trickly/node_modules/agenda-ui/lib/store.js:41:37)
    at Store.definitions (/Users/harel/dev/trickly/src/trickly/node_modules/agenda-ui/lib/store.js:69:26)

Agenda version 0.73 Agenda-ui version 0.0.7

harelba avatar Dec 03 '15 11:12 harelba

@harelba this is my working code changes.txt

pavan612 avatar Dec 03 '15 13:12 pavan612

var express = require('express');
var http = require('http');
var Agenda = require('agenda');
var agendaUI = require('agenda-ui');

var app = express();
var agenda = new Agenda({
  db: {
    address: 'localhost:27017/agenda-sample'
  }
}, function (err) {
  if (err) throw err;

  console.log('Connected to database');

  // Should add this code before setting middleware.
  agenda._db = agenda._collection;

  app.use('/agenda-ui', agendaUI(agenda, {poll: 1000}));

  http.createServer(app).listen(9000, function () {
    console.log('Express listeing on 9000 port');
  });

});

Check #17

jeonghwan-kim avatar Dec 08 '15 10:12 jeonghwan-kim

Thanks @pavan612 that hack worked :)

brebaje avatar Jan 12 '16 11:01 brebaje

I get the same error with @FLYBYME , I tried the solution suggested from @pavan612 but it didnt work. I'm using the latest versions from both agenda and agenda-ui. Any help? Does anyone make it work with the latest versions? Thanks

geototti21 avatar Jan 20 '16 16:01 geototti21

Hi can you post sample code of your problem

pavan612 avatar Jan 23 '16 03:01 pavan612

@pavan612 my code:

var agenda = new Agenda({db: {address: configDB.url, collection: "agendaJobs"}});

agenda.name(os.hostname() + '-' + process.pid); 

agenda.on('ready', function() {
  agenda.every('30 seconds', 'Say the time', {time: new Date()});
  agenda._db = agenda._collection;
  agenda.start();
});

//some session stuff there

app.use('/agenda-ui', agendaUI(agenda, {poll: 1000}));

//...

When I go to the the node terminal I have the same error with @FLYBYME and on the browser console the following:

error

geototti21 avatar Jan 26 '16 09:01 geototti21

Thanks @pavan612 that hack worked 2 :)

flashsnake-so avatar Feb 01 '16 05:02 flashsnake-so

same as @geototti21 . I doubt that the problem may relate to that the Agenda-UI is initializied before agenda connected to the database. I would like to know if it is possible to let Agenda-UI connect to the database on its own.

xfoxfu avatar Feb 01 '16 11:02 xfoxfu

For me the hacks doesn't works :-(

LeandroFavero avatar May 16 '16 21:05 LeandroFavero

So to get the hack to work and only init ui after agenda has connected to mongo I did this:

var agenda = new Agenda({db: { address: config.agendaDb } }, function() {
    // Should add this code before setting middleware.
    agenda._db = agenda._collection;
    app.use('/agenda-ui/', agendaUI(agenda, {poll: 1000}));
});

weareu avatar Jul 06 '16 20:07 weareu

Tried all solutions, none worked :-1:

vsmori avatar Mar 09 '17 22:03 vsmori

I got Agendash working very quickly with no issues so far. https://github.com/joeframbach/agendash

lusa avatar May 16 '17 15:05 lusa