Comments (5)
Same problem with trying to create an existing database. My expectation would be that the program should crash with non-zero exit code in these cases but it does not exit. I guess more error handling is needed for some promises.
$ ts-node scripts/create-db.ts
Unhandled rejection error: database "XXX" already exists
at Connection.parseE (C:\code\XXX\diaq-app\node_modules\pg\lib\connection.js:567:11)
at Connection.parseMessage (C:\code\XXX\diaq-app\node_modules\pg\lib\connection.js:391:17)
at Socket.<anonymous> (C:\code\XXX\diaq-app\node_modules\pg\lib\connection.js:129:22)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:588:20)
from knex-db-manager.
There are db connections left open, even when some queries fail. You need to add error handling and call https://vincit.github.io/knex-db-manager/#close and maybe https://vincit.github.io/knex-db-manager/#closeKnex to close connections (the same way that you need to call knex.destroy() when exitting app that has been using knex and has open connections in pool).
Connections cannot be closed automatically on error, because you actually might like to keep doing queries even when there has been an error.
from knex-db-manager.
Yes, you are correct. So I tried this, and it prints the closing messages but does not exit. Maybe I am doing something else wrong...
dbManager.createDb()
.catch((e) => {
console.log(`Error occured when creating database: ${e}`);
dbManager.close().then(() => console.log("closed connection 1"));
dbManager.closeKnex().then(() => console.log("closed connection 2"));
});
Error occured when creating database: error: database "XXX" already exists
closed connection 2
closed connection 1
from knex-db-manager.
It seems this is more of a knex issue. I can reproduce using a simple Knex instance, doing a .raw() call and then calling knex.destory(). It still does not exit. Seems like the same problem as in this comment.
from knex-db-manager.
I'll check out if I can reproduce this with knex and report the error (+ maybe also fix it).
from knex-db-manager.
Related Issues (20)
- An in-range update of coveralls is breaking the build 🚨 HOT 1
- populateDb expects seed files that export a function, but knex seed files exports.seed HOT 6
- An in-range update of mocha is breaking the build 🚨 HOT 4
- An in-range update of knex is breaking the build 🚨 HOT 2
- An in-range update of mysql is breaking the build 🚨 HOT 1
- No information on collation / charset HOT 5
- An in-range update of pg is breaking the build 🚨 HOT 13
- An in-range update of knex is breaking the build 🚨 HOT 1
- An in-range update of coveralls is breaking the build 🚨 HOT 4
- dbManager.createDb > Warning: a promise was rejected with a non-error: [object Undefined] HOT 9
- SSL Not supported - Postgres HOT 1
- The encoding/charset is hard coded to 'utf8' HOT 1
- databaseManagerFactory doesn't work when the Knex config uses a database URL as the connection property HOT 6
- `truncateDb` does not work with objection's `knexSnakeCaseMappers` HOT 5
- truncateDb does not work on macOS HOT 2
- Support for UNIX sockets HOT 1
- MSSQL support HOT 1
- knex timeout on migrateDb() call HOT 1
- dbManager.truncateDb - cannot truncate a table referenced in a foreign key constraint HOT 1
- Update knex dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knex-db-manager.