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.

TypeError - Cannot read property 'on' of undefined

See original GitHub issue

What you are doing?

I’m running Red Hat Enterprise Linux Server 7.2 (Maipo) and can’t seem to get my models to sync. Strangely, it used to sync up before, but after deleting the models (and also the cascaded objects), I can’t seem to get sync working anymore. It works locally on my OS X using the exact same code.

Edit: It stopped working locally after I cleared my npm cache and reinstalled all my node modules.

One of my models looks like this, with its syntax correct - verified and checked:

var Pizza = sequelize.define('pizza', {
    translated:     Sequelize.JSON,
    related:        Sequelize.ARRAY(Sequelize.STRING),
    native:         Sequelize.STRING,
    stripped:       Sequelize.STRING
});

What do you expect to happen?

My database should sync the new models up.

What is actually happening?

I keep getting this error (n number of times the amount I call sync() on my models) and the error message doesn’t really help me resolve or debug.

Unhandled rejection TypeError: Cannot read property 'on' of undefined
    at /home/path/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:158:9
    at Promise._execute (/home/path/node_modules/bluebird/js/release/debuggability.js:299:9)
    at Promise._resolveFromExecutor (/home/path/node_modules/bluebird/js/release/promise.js:481:18)
    at new Promise (/home/path/node_modules/bluebird/js/release/promise.js:77:14)
    at /home/path/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:155:12
    at PassThroughHandlerContext.finallyHandler (/home/path/node_modules/bluebird/js/release/finally.js:56:23)
    at PassThroughHandlerContext.tryCatcher (/home/path/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/path/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/path/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/path/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/path/node_modules/bluebird/js/release/promise.js:691:18)
    at Async._drainQueue (/home/path/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/home/path/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/home/path/node_modules/bluebird/js/release/async.js:17:14)
    at ZoneDelegate.invokeTask (/home/path/node_modules/zone.js/dist/zone-node.js:225:37)
    at Zone.runTask (/home/path/node_modules/zone.js/dist/zone-node.js:125:47)

What is on referring to and how can I resolve this problem? Bug?

Dialect: postgres Database version: 9.2.15 Sequelize version: 3.24.3

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jvbianchicommented, Sep 20, 2016

I have the same error, when you rollback zone.js to version 0.6.21 the error goes way. Looks like its a problem with the newest version of zone.js

it might be related with https://github.com/angular/zone.js/issues/455

0reactions
stale[bot]commented, Jun 29, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >
[Solved] Cannot read Properties of Undefined in JavaScript
The "Cannot read properties of undefined" error occurs when you try to access a property or a method on a variable that stores...
Read more >
Uncaught TypeError : Cannot read properties of undefined
The solution to TypeError: Cannot read properties of undefined ... The root cause of the error is that the declared variable doesn't have...
Read more >
Node.js Cannot read property 'on' of undefined - Stack Overflow
TypeError : Cannot read property 'on' of undefined at Object.<anonymous> (E:\Project\node\BasicSocial\server.js:12:2) ...
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