Ошибка, по-видимому, возникает при выполнении connection.close и connection.run близко друг к другу, когда вызов run находится в setInterval / setTimeout или других обратных вызовах.
См. Пример файла index.js. Запустите егос помощью простой команды "узел index.js".Попробуйте запустить несколько раз.
//
// Nodejs version: 8.9.1
// Os version: Windows 7 64 bit (Intel i7)
// Dependencies: "sqlite3": "^4.0.2" (but it occurs also in version 3.x.x)
// Problem: one in around ten executions using "node index.js" the application exits without signals, errors and is not possible to catch the error/exit
var sqlite3 = require('sqlite3');
var db = new sqlite3.Database(':memory:');
setInterval(function(){
console.log("Application tick!"); //this should prevent application finish
}, 1000);
process.on('uncaughtException', function (err) {
console.log("uncaughtException", err);
});
process.on('unhandledRejection', function (err) {
console.log("unhandledRejection", err);
});
process.on('rejectionHandled', function(promise) {
console.log("rejectionHandled");
unhandledRejections.delete(promise);
});
process.on('exit', function (code) {
console.log("exit", code);
});
setInterval(function(){
db.run("FAKE SQL STMT", (err) => { //the sql stmt is not important. The error occurs with both a real and correct stmt or with this fake stmt
console.log("Sql error: " + err);
});
}, 0);
db.close((err) => {
console.log("Close error: " + err);
});