You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into a potential issue and I'm not 100% sure if it's a bug with the mysql connection manager or something I'm doing.
When triggering a connection failure on sequelize.sync() the error events do not seem to propagate up out of the connection-manager.js I've attached an event listener using the .error() method on the sequelize.sync() which works perfectly with sqlite. But when using mysql the callback is never triggered.
varSequelize=require("sequelize");varsequelize=newSequelize(database,user,pass,_opts);// Defined Modelssequelize.sync().success(function(){console.log("Models Synced");}).error(function(err){console.log("Error: OOOH NOOOES");});
The above will generate the following error
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at EventEmitter.emit (events.js:74:15)
at Handshake._callback (./node_modules/sequelize/lib/dialects/mysql/connector-manager.js:278:19)
at Handshake.Sequence.end (./node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Protocol.handleNetworkError (./node_modules/mysql/lib/protocol/Protocol.js:238:14)
at Connection._handleNetworkError (./node_modules/mysql/lib/Connection.js:155:18)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:830:16
at process._tickCallback (node.js:415:13)
22 Oct 23:49:29 - [nodemon] app crashed - waiting for file changes before starting...
Executing (default): SELECT * FROM `users` WHERE `users`.`name`='foo' LIMIT 1;
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
fatal: true }
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>:null:null)
at EventEmitter.emit (events.js:74:15)
at Handshake._callback (/home/foohey/dev/nodejs/awale/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:283:19)
at Handshake.Sequence.end (/home/foohey/dev/nodejs/awale/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Protocol.handleNetworkError (/home/foohey/dev/nodejs/awale/node_modules/mysql/lib/protocol/Protocol.js:255:14)
at Connection._handleNetworkError (/home/foohey/dev/nodejs/awale/node_modules/mysql/lib/Connection.js:187:18)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:441:14
at process._tickCallback (node.js:415:13)
and try/ctach doesn't help
EDIT
I just realized that there is a mariadb dialect & mariasql lib. Now everything work good
TypeError: Uncaught, unspecified "error" event. is thrown when you forget to attach an error listener to an emitter (i.e. you are only listening to success).
Are you calling another method, perhaps sync, where you aren't attaching an error listener?
Hi guys. Thanks for reporting the issue. This is a known issue. The major issue is, that we don't return the emitter to the outer world and because of that its not possible to catch the error. It will be fixed in the final 1.7.0.
Hi. I get the same error only on debian. But on windows everything is ok.
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Uncaught, unspecified 'error' event.
at EventEmitter.emit (events.js:50:15)
at Handshake._callback (/home/er1234/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:283:19)
at Handshake.end (/home/er1234/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Protocol.handleNetworkError (/home/er1234/node_modules/mysql/lib/protocol/Protocol.js:261:14)
at Connection._handleNetworkError (/home/er1234/node_modules/mysql/lib/Connection.js:187:18)
at Socket. (native)
at Socket.emit (events.js:88:20)
at Array.0 (net.js:319:25)
at EventEmitter._tickCallback (node.js:192:40)
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize('database', 'name', 'password', {
host: '127.0.0.1', // or host: 'localhost'
dialect: 'mysql',
port: 5043, // your port
dialectOptions: { // optional if you have xampp or port borken
socketPath: "/opt/lampp/var/mysql/mysql.sock"
},
})
Activity
m4tm4t commentedon Dec 23, 2013
Same here but with find method. I tried to shutdown mysql and the app is crashing. (2.0.0-beta.2)
and try/ctach doesn't help
EDIT
I just realized that there is a mariadb dialect & mariasql lib. Now everything work good
mickhansen commentedon Dec 23, 2013
TypeError: Uncaught, unspecified "error" event.is thrown when you forget to attach an error listener to an emitter (i.e. you are only listening to success).Are you calling another method, perhaps sync, where you aren't attaching an error listener?
m4tm4t commentedon Dec 23, 2013
But look my code, there is an error listener, and the
console.log(err)is working toomickhansen commentedon Dec 23, 2013
Ah, you're right - What are your connection settings? (Pooling etc)
m4tm4t commentedon Dec 23, 2013
SkPhilipp commentedon Jan 4, 2014
( sequelize 1.7.0-beta.4a, mysql 2.0.0-rc2 , node 0.10, windows )
Experienced the same issue when referencing a database that does not exist in MySQL.
My code:
( After that i also call a bunch of
sequelize#definefollowed bysequelize#sync. )Didn't debug further, creating the database
demosolved the issue for me.acoll commentedon Jan 8, 2014
I'm getting the same error. The stack trace pointed me to this code https://github.com/sequelize/sequelize/blob/master/lib/dialects/mysql/connector-manager.js#L260.
Notice that the emitter isn't accessible but emits the error event. So you can't actually add a listener for it.
sdepold commentedon Jan 8, 2014
Hi guys. Thanks for reporting the issue. This is a known issue. The major issue is, that we don't return the emitter to the outer world and because of that its not possible to catch the error. It will be fixed in the final 1.7.0.
stigmat4j commentedon Jan 13, 2014
Hi. I get the same error only on debian. But on windows everything is ok.
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Uncaught, unspecified 'error' event.
at EventEmitter.emit (events.js:50:15)
at Handshake._callback (/home/er1234/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:283:19)
at Handshake.end (/home/er1234/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Protocol.handleNetworkError (/home/er1234/node_modules/mysql/lib/protocol/Protocol.js:261:14)
at Connection._handleNetworkError (/home/er1234/node_modules/mysql/lib/Connection.js:187:18)
at Socket. (native)
at Socket.emit (events.js:88:20)
at Array.0 (net.js:319:25)
at EventEmitter._tickCallback (node.js:192:40)
sdepold commentedon Jan 20, 2014
Will take care of that during the week.
mickhansen commentedon Jan 22, 2014
Should be fixed by: #1282
mickhansen commentedon Jan 22, 2014
Please re-open if not fixed by PR.
msjahid commentedon Jun 27, 2022