voxpelli / node-connect-pg-simple

A simple, minimal PostgreSQL session store for Express
https://www.npmjs.com/package/connect-pg-simple
MIT License
234 stars 74 forks source link

Getting "Pool is missing for some Reasons", If not there is no communication between Client and server for more than 24 hours #313

Closed pst37 closed 4 months ago

pst37 commented 4 months ago

I am passing pool object to the pg connect simple . After 24 hours or more I am getting Pool is missing for some reason. It will be great if any one can help

const PgSession = require('connect-pg-simple')(session);
const { Pool } = require('pg');

 pgPool = new Pool({
        user: POSTGRES_USER,
        host: host ,
        database: DB_NAME,
        password: password,
        port: port,
        allowExitOnIdle:false,
        keepAlive:true,
      });

let config = {
    secret: 'some_random_session',
  resave: false,
  saveUninitialized: false,
  rolling: true
  store:new PgSession({
    pool: pgPool,
    tableName: TABLE_NAME
  });
}

    sessionMiddleware = session(config);

Earlier I was not passing allowExitOnIdle:false and keepAlive:true, . even if I added , I am getting this error.

image

When I am saying client it's basically Frontend.

voxpelli commented 4 months ago

The only place that message is printed is here:

https://github.com/voxpelli/node-connect-pg-simple/blob/21e41c445318a5337cc155fd8dad5820601b6ef2/index.js#L320

And it can't change during the lifetime of the script, its only ever assigned in two places:

https://github.com/voxpelli/node-connect-pg-simple/blob/21e41c445318a5337cc155fd8dad5820601b6ef2/index.js#L127

https://github.com/voxpelli/node-connect-pg-simple/blob/21e41c445318a5337cc155fd8dad5820601b6ef2/index.js#L146

So, from the perspective of connect-pg-simple it doesn't matter if its 1 second or 24 hours that passes by, if the pool is ever found then it should be forever found. Maybe its something else in your setup that changes?

pst37 commented 4 months ago

Yaa, this is not the issue of connect-pg-simple