Reputation: 2011
I recently had to upgrade my node.js version for my vue.js application (node.js on the backend) from v13.5.0 to v14.5.0. I reinstalled all my node packages, upgrading the ones I had to upgrade, and now the application hangs on all DB calls. We are using pg (node-postgres) for our database calls. I upgraded pg to version 7.18.2.
Our initialization code looks like this:
constructor() {
this.pg = require('pg');
this.client = null;
this.initPromise = null;
}
async init() {
if (!this.initPromise) {
this.client = new this.pg.Client({
application_name: 'Back end',
ssl: {
rejectUnauthorized: false
}
});
this.initPromise = this.client.connect();
}
return this.initPromise;
}
async query(query, params) {
await this.init();
return await this.client.query(query, params);
}
I put console logs around the call to this.init() as follows:
console.log('before');
await this.init();
console.log('after');
'after' never prints out.
Does anyone know why it hangs now that I've upgrade my node version?
Upvotes: 5
Views: 4807
Reputation: 21
@gib65 upgrading to v.8.3.0 did the trick for me too was banging my head on await and async. thought i was being a n00b again...
Upvotes: 0
Reputation: 2011
It seems that pg v.8.3.0 solves this problem. I got v7.18.2 from running npm install pg. Seems that doesn't always install the latest version. npm install pg@latest does the trick.
Upvotes: 14