Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to Postgres with Node v14 #7022

Open
alxndrsn opened this issue Aug 5, 2020 · 5 comments
Open

Cannot connect to Postgres with Node v14 #7022

alxndrsn opened this issue Aug 5, 2020 · 5 comments
Labels
node version issue postgresql Issue only occurs when using PostgreSQL resolved

Comments

@alxndrsn
Copy link

alxndrsn commented Aug 5, 2020

Node version: 14.x: tested on 14.0.0, 14.5.0, 14.7.0
Sails version (sails): 1.2.4
ORM hook version (sails-hook-orm): 2.1.1
DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql@1.0.2


Observed

Database connection times out on app startup when using node version 14. Node 12 and 13 seem to work fine:

Working with node 12:

$ nvm use 12 && npx sails console
Now using node v12.18.2 (npm v6.14.5)

 info: Starting app in interactive mode...

 info: ·• Auto-migrating...  (drop)
 info:  ✓ Auto-migration complete.

 info: Welcome to the Sails console.
 info: ( to exit, type <CTRL>+<C> )

(node:20084) [DEP0124] DeprecationWarning: REPLServer.rli is deprecated

Broken with node 14:

$ nvm use 14 && npx sails console
Now using node v14.7.0 (npm v6.14.7)

 info: Starting app in interactive mode...

(node:19845) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
 info: ·• Auto-migrating...  (drop)
error: 
error: Error: Sails is taking too long to load.

--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
 Troubleshooting tips:
  -• Were you still reading/responding to an interactive prompt?
     (Whoops, sorry!  Please lift again and try to respond a bit more quickly.)

  -• Do you have a lot of stuff in `assets/`?  Grunt might still be running.
    (Try increasing the hook timeout.  Currently it is 40000.
     e.g. `sails lift --hookTimeout=80000`)

  -• Is `blueprints` a custom or 3rd party hook?
    (*If* `initialize()` is using a callback, make sure it's being called.)
--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --

    at Timeout.tooLong [as _onTimeout] (/home/user/workspaces/sails/node14pg/node_modules/sails/lib/app/private/loadHooks.js:191:21)
    at listOnTimeout (internal/timers.js:551:17)
    at processTimers (internal/timers.js:494:7)

error: Could not load Sails app.
error: 
error: Tips:
error:  • First, take a look at the error message above.
error:  • Make sure you've installed dependencies with `npm install`.
error:  • Check that this app was built for a compatible version of Sails.
error:  • Have a question or need help?  (http://sailsjs.com/support)

Expected

Upgrading to latest node should not break the db connection.

Steps to recreate

(requires local postgresql and correct permissions to connect)

git clone git@github.com:alxndrsn/sails-postgres-node-14.git
cd sails-postgres-node-14
yarn
nvm install 14
nvm use 14
export DATABASE_URL=postgres://user:password@localhost/db_name
npx sails console

Possibly related

There are a number of other projects reporting issues with node 14 and pg:

It sounds like updating the pg dependency might fix the issue.

@sailsbot
Copy link

sailsbot commented Aug 5, 2020

@alxndrsn Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

  • look for a workaround. (Even if it's just temporary, sharing your solution can save someone else a lot of time and effort.)
  • tell us why this issue is important to you and your team. What are you trying to accomplish? (Submissions with a little bit of human context tend to be easier to understand and faster to resolve.)
  • make sure you've provided clear instructions on how to reproduce the bug from a clean install.
  • double-check that you've provided all of the requested version and dependency information. (Some of this info might seem irrelevant at first, like which database adapter you're using, but we ask that you include it anyway. Oftentimes an issue is caused by a confluence of unexpected factors, and it can save everybody a ton of time to know all the details up front.)
  • read the code of conduct.
  • if appropriate, ask your business to sponsor your issue. (Open source is our passion, and our core maintainers volunteer many of their nights and weekends working on Sails. But you only get so many nights and weekends in life, and stuff gets done a lot faster when you can work on it during normal daylight hours.)
  • let us know if you are using a 3rd party plugin; whether that's a database adapter, a non-standard view engine, or any other dependency maintained by someone other than our core team. (Besides the name of the 3rd party package, it helps to include the exact version you're using. If you're unsure, check out this list of all the core packages we maintain.)

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

@alxndrsn
Copy link
Author

alxndrsn commented Aug 5, 2020

For anyone following this and wanting an immediate fix, I had to change the sails-postgresql depedency to sails-postgresql-redacted@1.0.2-5.

If you're also using connect-pg-simple, you'll need to replace that with https://github.com/nstuyvesant/node-connect-pg-simple.git#adcb6c4642db88e6de47e3aea48a71b5ab3569fa until voxpelli/node-connect-pg-simple#174 is merged & released.

@eashaw
Copy link
Member

eashaw commented Aug 5, 2020

Thank you @alxndrsn for the workaround, we will be working on updating sails-postgresql to work with Node 14 this month

@rachaelshaw
Copy link
Member

@alxndrsn @eashaw just released sails-postgresql v2.0.0, which is updated to support Node v14

@GirkovArpa
Copy link

Is this bounty still open? It's offering $15 to solve this issue which appears to be already solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
node version issue postgresql Issue only occurs when using PostgreSQL resolved
Development

No branches or pull requests

5 participants