sequelize: Sequelize misbehaving with Node v14

Today I upgraded to Node v14. However, I run into some interesting issue, most probably with Sequelize.

The problem that I run into is that in a normal execution of my app, sequelize will never return from the queries. However, if I run my program using VSCode debug, it goes through without problems. I have tried it with both v5.21.7 and v6.0.0.-beta.5

Below is the package.json that I have. Note that CLS is not used for Sequelize. I was hoping to replace CLS with Node v14 AsyncLocalStorage.

{
  "name": "backend",
  "version": "1.0.0",
  "main": "app.js",
  "author": "",
  "license": "MIT",
  "scripts": {
    "start": "babel-node src/app.js",
    "dev": "nodemon --watch src --exec BABEL_DISABLE_CACHE=1 babel-node src/app.js",
    "lint": "eslint --fix src",
    "clean": "rimraf dist",
    "build": "babel src -d dist --source-maps --copy-files",
    "build_prod": "babel src -d dist --copy-files",
    "clean-build": "yarn run clean && yarn run build"
  },
  "devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.9.0",
    "@babel/node": "^7.8.7",
    "@babel/preset-env": "^7.9.5",
    "babel-polyfill": "^6.26.0",
    "eslint": "^6.8.0",
    "jsdoc": "^3.6.4",
    "rimraf": "^3.0.2"
  },
  "dependencies": {
    "babel-plugin-inline-dotenv": "^1.5.0",
    "bcrypt": "^4.0.1",
    "body-parser": "^1.19.0",
    "continuation-local-storage": "^3.2.1",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "express-session": "^1.17.0",
    "jsonwebtoken": "^8.5.1",
    "nodemon": "^2.0.3",
    "pg": "^8.0.2",
    "pg-hstore": "^2.3.3",
    "sequelize": "^5.21.7",
    "sequelize-cli": "^5.5.1"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 44
  • Comments: 53 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I have some findings. I tried with a very simple project and it worked. I examined the differences between the packages of this simple project and the project where I faced the issue that I reported and I noticed that in the working project, I had pg@8.0.3. When I installed version 8.0.2 of pg it failed with node v14 (silently) but worked with version 13.13.0. With this in mind I believe that upgrading pg@8.0.3 may resolve the problem. Note, that pg@8.0.3 was only released yesterday.

When I upgraded the failing project to pg@8.0.3 it worked without a problem.

I have the same problem, the sequelize.authenticate() method doesn’t resolve, without any error.

I can confirm that the issue is node v14, when we downgrade to 13.x.x the issue goes away. We are using sequelize 5.21.7.

The issue we experience is: any sequelize call (sync, findOne, etc) hangs indefinitely with no error messages. For us, this caused Heroku to time out our servers main process.

Yes @kororos, upgrading pg@8.0.3 did resolve the problem.

Thanks @kororos ! Updating pg worked for me too.

upgrading to pg@8.0.3 resolve the problem with node v14

My good silent errors are the worst at all for any developer after 2 days. Anyway thanks for your tips, I upgraded to : "pg": "^8.7.3", "pg-hstore": "^2.3.4", "sequelize": "^6.20.1", "sequelize-cli": "^6.4.1", and my node version is v18.2.0. After making the upgrade I can see typical errors and now works perfect.

Be careful devs and I hope this helps for some one else 😃

Exactly the issue I met just now.

It is hard to find this issue from internet before realizing what the problem is, and it is easy to find this issue immediately after finding out the reason.

What a paradox 😹

Upgrading the pg version solves the issue. It seems to be an issue with node version > 14.

Upgrading to ^8.0.3 works. I think this issue can be closed.

I’ll close this issue as it’s now documented that only pg 8 supports Node >= 14: https://sequelize.org/v6/manual/dialect-specific-things.html#postgresql

I would recommend upgrading to Sequelize 6, as Sequelize < 6 is not maintained anymore and we can’t guarantee that they will continue working with more recent versions of node, or pg.

I can confirm that upgrading to pg 8+ worked (with node 14.17.1)

    "pg": "8.6.0",
    "sequelize": "4.44.4"

Beforehand we had pg 6 + in one of our dependencies which caused a connect method to not resolve.

exact same problem. resolved by updating pg from 7.x to 8.x latest: npm install pg@latest.

express js / nodejs hangs in node bin/www without printing Listening on port xxxx. It turned out the models.sequelize.sync() call never returns. This happened after upgrading node to 14.x and also upgrading the mac machine to big sur.

The problem I think is in pg and not sequelize. sequelize.authenticate() doesn’t resolve because pg.client.connect() doesn’t. sqlite on the other hand works fine.

My good silent errors are the worst at all for any developer after 2 days. Anyway thanks for your tips, I upgraded to : "pg": "^8.7.3", "pg-hstore": "^2.3.4", "sequelize": "^6.20.1", "sequelize-cli": "^6.4.1", and my node version is v18.2.0. After making the upgrade I can see typical errors and now works perfect.

Be careful devs and I hope this helps for some one else 😃

Tried this and didn’t work 😞

Had the same issue, no error or any message, updating the pg package worked for me while upgrading to Node 16.

Code had:

await database.authenticate();

This is on a legacy app with Sequelize 4. A google search took me here.

Just found the reason for my problem… First I was trying findOne with the following code:

const organisationInfo: ITPSharedData = await ITPSharedData.findOne({ where: { organisation_id: "8292c33e-d95a-5fe7-8f27-dd7a95c68b55" } });

The code above was hanging without any error message… Then I tried with code below:

ITPSharedData.findOne({ where: { organisation_id: "8292c33e-d95a-5fe7-8f27-dd7a95c68b55" } })
        .then(a => {
            console.log(a);
        })
        .finally(() => {
            sequelize.close();
        });

And it “worked”, showing the error message and the error was that sequelize was adding in the query the columns createdAt and updatedAt, and I don’t have these columns on my table, so to make sequelize work without these columns I had to define my sequelize instance as below:

const sequelize = new Sequelize("mysql://<user>:<pass>@<server>:<port>/<db>",
    {   
        define: {
            timestamps: false
        }
    }
);    

and now my code with await works

@papb upgrading from ^7.17.0 to ^8.5.1 did the trick for me.

Spent 2 days on this issue. Promises don’t resolve or reject. Noticed my node version was 14 for “some reason” on the third day

went back to node 10 and it worked as expected

if node 14 doesn’t work, a warning or error would have been welcomed! 😅

The first hypothesis that comes to my mind is that something is wrong with Bluebird in Node 14…