Fix for sqlite not retrying to open database (and crashing)

Fix for #106
This commit is contained in:
dceejay 2015-03-18 08:47:09 +00:00
parent 5a27ce17e8
commit 87a8814fe0
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-sqlite", "name" : "node-red-node-sqlite",
"version" : "0.0.4", "version" : "0.0.5",
"description" : "A sqlite node for Node-RED", "description" : "A sqlite node for Node-RED",
"dependencies" : { "dependencies" : {
"sqlite3" : "3.0.*" "sqlite3" : "3.0.*"

View File

@ -32,9 +32,9 @@ module.exports = function(RED) {
node.log("opened "+node.dbname+" ok"); node.log("opened "+node.dbname+" ok");
}); });
node.db.on('error', function(err) { node.db.on('error', function(err) {
node.warn(err); node.error(err);
node.log("failed to open "+node.dbname); node.log("failed to open "+node.dbname);
node.tick = setTimeout(doConnect, reconnect); node.tick = setTimeout(function() { node.doConnect(); }, reconnect);
}); });
} }
@ -59,7 +59,7 @@ module.exports = function(RED) {
//console.log("query:",msg.topic); //console.log("query:",msg.topic);
var bind = Array.isArray(msg.payload) ? msg.payload : []; var bind = Array.isArray(msg.payload) ? msg.payload : [];
node.mydbConfig.db.all(msg.topic, bind, function(err, row) { node.mydbConfig.db.all(msg.topic, bind, function(err, row) {
if (err) { node.warn(err); } if (err) { node.error(err,msg); }
else { else {
msg.payload = row; msg.payload = row;
node.send(msg); node.send(msg);
@ -68,7 +68,7 @@ module.exports = function(RED) {
} }
else { else {
if (typeof msg.topic !== 'string') { if (typeof msg.topic !== 'string') {
node.error("msg.topic : the query is not defined as a string"); node.error("msg.topic : the query is not defined as a string",msg);
} }
} }
}); });