question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

connect-pg-simple takes 10s to shutdown

See original GitHub issue

Node version: 10.16.0 Sails version (sails): 1.2.3 ORM hook version (sails-hook-orm): DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql 1.0.2


connect-pg-simple takes 10s to shutdown at the end of tests.

Example project at: https://github.com/alxndrsn/sailsjs-connect-pg-simple-shutdown-delay

To recreate:

git clone https://github.com/alxndrsn/sailsjs-connect-pg-simple-shutdown-delay
cd sailsjs-connect-pg-simple-shutdown-delay
$ yarn test
...
  connect-pg-simple leaves a hanging promise
    ✓ leaves a hanging promise...


  1 passing (542ms)

Done.
Done in 11.73s.
$ IN_MEMORY_SESSIONS=true yarn test
...
  connect-pg-simple leaves a hanging promise
    ✓ leaves a hanging promise...


  1 passing (530ms)

Done.
Done in 1.70s.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alxndrsncommented, Oct 29, 2019

This also prevents sails console or sails lift from shutting down quickly.

Again this can be worked around by calling sails.config.session.store.close(); in the callback from sails.lift() in app.js:

// Start server
sails.lift(rc('sails'), err => {
  if(err) {
    console.error('Failed to lift app:', err);

    try {
      sails.config.session.store.close();
    } catch(err2) {
      console.error('Error caught trying to shut down postgres session store:', err2);
    }

    return;
  }

  sails.log.verbose('App lifted successfully.');
});
1reaction
alxndrsncommented, Jul 19, 2019

It seems you can work around this by manually destroying the session postgresql pool, using sails.config.session.store.close();.

In the example project, this can be done by changing test/config.js to:

const sails = require('sails');

before(done => {
  sails.lift({}, err => {
    if (err) { return done(err); }
    return done();
  });
});

after(done => {
  sails.lower(() => {
    sails.config.session.store.close();
    done();
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

connect-pg-simple - npm
A simple, minimal PostgreSQL session store for Connect/Express. Latest version: 8.0.0, last published: 2 months ago.
Read more >
Switching out of S mode in Windows - Microsoft Support
On your PC running Windows 11 in S mode, open Settings > System > Activation. · In the Switch to Windows 11 Pro...
Read more >
Restart your iPhone - Apple Support
Press and hold either volume button and the side button until the power-off slider appears. The volume button is located on the left...
Read more >
How to turn off News And Interests in Windows 10's taskbar
Windows 10's News and Interests taskbar tool is a handy feature for ... taking up space on your taskbar, however, getting rid of...
Read more >
Android Beta Program - Google
Android Beta for Pixel offers you a simple way to try pre-release versions of ... into with your Google account as the primary...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found