createConnection close api without throw error.
See original GitHub issueIssue Description
Expected Behavior
create a connection with postgres database.
Actual Behavior
Without make any change in database connection, the api, suddenly, exit and the code pass through the createConnection method.
Steps to Reproduce
require('dotenv').config();
import 'reflect-metadata';
import * as Server from './server';
import * as entities from './database';
import { Connection, createConnection } from 'typeorm';
import { DataConfig, getConfigs } from './configurations';
console.log(`Running enviroment ${process.env.NODE_ENV}`);
const initDatabase = async (dataConfig: DataConfig): Promise<Connection> => {
try {
const connection = await createConnection({
type: 'postgres',
host: dataConfig.host,
port: dataConfig.port,
username: dataConfig.username,
password: dataConfig.password,
database: dataConfig.database,
entities: Object.keys(entities).map(key => entities[key]),
logging: false,
});
return connection;
} catch (err) {
console.error('Error connection database: ', err.message);
throw err;
}
};
const start = async () => {
try {
const configs = getConfigs();
console.log('Get configs successfully.');
await initDatabase(configs.dataConfig);
console.log('Database connected successfully.');
const server = await Server.init(configs);
await server.start();
console.log('Server running at:', server.info.uri);
} catch (err) {
console.error('(1) Error starting server: ', err.message);
throw err;
}
};
start()
.then(() => {
console.log('Ready to receive requests!');
})
.catch(err => {
console.error('(2) Error starting server: ', err);
process.exit(1);
});
My Environment
“dependencies”: { “pg”: “^7.18.2”, “typeorm”: “^0.3.0-alpha.24”, “node”: “13.10.1”, }, “devDependencies”: { “@types/dotenv”: “^8.2.0”, “@types/node”: “^13.9.0”, “@types/pg”: “^7.14.4”, “typescript”: “^3.8.3”, }
Relevant Database Driver(s)
-
aurora-data-api
-
aurora-data-api-pg
-
better-sqlite3
-
cockroachdb
-
cordova
-
expo
-
mongodb
-
mysql
-
nativescript
-
oracle
-
postgres
-
react-native
-
sap
-
sqlite
-
sqlite-abstract
-
sqljs
-
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time, and I know how to start.
- Yes, I have the time, but I don’t know how to start. I would need guidance.
- No, I don’t have the time, although I believe I could do it if I had the time…
- No, I don’t have the time and I wouldn’t even know how to start.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Properly close mongoose's connection once you're done
I'm using mongoose in a script that is not meant to run continuously, and I'm facing what ...
Read more >Net | Node.js v19.3.0 Documentation
The node:net module provides an asynchronous network API for creating stream-based TCP or IPC servers ( net.createServer() ) and clients ( net.createConnection ......
Read more >Connection (Java Platform SE 7 ) - Oracle Help Center
Returns true if the connection has not been closed and is still valid. ... Throws: SQLException - if a database access error occurs,...
Read more >Node.js with MySQL - w3resource
node-mysql: A node.js module implementing the MySQL protocol · Install MySQL node.js driver · Create connection · Error handling · SSL options.
Read more >Connection Pools with MariaDB Connector/Node.js (Promise ...
The parent of this page is: MariaDB Connector/Node.js with Promise API ... The createPool(options) function does not return a Promise , and therefore...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems to be related to a specific (range) of pg / pg-connection-string. I was able to upgrade pg and that seemingly resolved the issue.
I have same problem recently. And, upgrade to “pg”: “8.3.3”, “typeorm”: “0.2.25”, works for me.