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
Maybe I'm missing something, but since the instantiation of the Schema class automatically does the connect behind the scenes without a callback, there is no way to gracefully handle connection errors.
Most other ORMs seem to provide a connect function with a callback that passes back an err object, as is the case when you perform a find operation with JugglingDB. If for some reason the server is unable to connect I want to gracefully handle the error and not kill the process. I could use Node's domains to catch the error, but it would be so much simpler to just have a callback. I see there is an event emitted when JugglingDB has connected, but other than that, what am I supposed to do? I rather like the this ORM (minus the thorough documentation), but this seems like a simple thing thats missing?
The text was updated successfully, but these errors were encountered:
After posting a question about proper ways to handle errors with this as a specific example to Stack Overflow: Understanding Try/Catch and Domains for Error Handling in Node; I was shown that when pooling is turned off (using the mysql adapter), JugglingDB logs the error and retries the connection. This is certainly better behavior, but honestly I feel like it should still emit or return the error via a callback so I can handle things my own way, just like any other ORM.
That said, when pooling is turned on, catchable errors are thrown when they should be returned via callback or emitted. See the following stack trace:
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
--------------------
at Protocol._enqueue /Sites/site/node_modules/jugglingdb-mysql/node_modules/mysql/lib/protocol/Protocol.js:110:48)
at Protocol.handshake (/Sites/site/node_modules/jugglingdb-mysql/node_modules/mysql/lib/protocol/Protocol.js:42:41)
at PoolConnection.Connection.connect (/Sites/site/node_modules/jugglingdb-mysql/node_modules/mysql/lib/Connection.js:101:18)
at Pool.getConnection (/Sites/site/node_modules/jugglingdb-mysql/node_modules/mysql/lib/Pool.js:42:23)
at Pool.query (/Sites/site/node_modules/jugglingdb-mysql/node_modules/mysql/lib/Pool.js:185:8)
at initDatabase (/Sites/site/node_modules/jugglingdb-mysql/lib/mysql.js:62:20)
at initializeConnection (/Sites/site/node_modules/jugglingdb-mysql/lib/mysql.js:49:9)
at Object.initializeSchema [as initialize] (/Sites/site/node_modules/jugglingdb-mysql/lib/mysql.js:33:5)
at new Schema (/Sites/site/node_modules/jugglingdb/lib/schema.js:105:13)
at Application.loadConnections (/Sites/site/core/application.js:95:40)
Process finished with exit code 8
Maybe I'm missing something, but since the instantiation of the Schema class automatically does the connect behind the scenes without a callback, there is no way to gracefully handle connection errors.
Most other ORMs seem to provide a connect function with a callback that passes back an err object, as is the case when you perform a find operation with JugglingDB. If for some reason the server is unable to connect I want to gracefully handle the error and not kill the process. I could use Node's domains to catch the error, but it would be so much simpler to just have a callback. I see there is an event emitted when JugglingDB has connected, but other than that, what am I supposed to do? I rather like the this ORM (minus the thorough documentation), but this seems like a simple thing thats missing?
The text was updated successfully, but these errors were encountered: