Saturday, 8 April 2017

Error with query sending Unhandled rejection SequelizeConnectionError: read ECONNRESET

PostgreSQL 9.6.2 windows 10 x64. I send query from node.js application.

Controller

authorize(req).then(function (foundUser) {
  //get data from db and send it for client
}), function (err) {
  res.status(200).send('User not found');
}

authorize.js

module.exports = function (req) {
  var decodeToken = jwt.decode(req.cookies.token, JwtOptions.secretOrKey);
  return db.users.findById(decodeToken.id)
    .then(function (foundUser) {
      return foundUser;
  }).catch(function (err) {
    //get here the exception
    return err;
  });
}

Sometimes I get data from db and sometimes get an error:

Unhandled rejection SequelizeConnectionError: read ECONNRESET
    at D:\NodeJSProjects\ParkingHouse\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:110:20
    at Connection.<anonymous> (D:\NodeJSProjects\ParkingHouse\node_modules\pg\lib\client.js:186:5)
    at emitOne (events.js:96:13)
    at Connection.emit (events.js:188:7)
    at Socket.<anonymous> (D:\NodeJSProjects\ParkingHouse\node_modules\pg\lib\connection.js:86:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1278:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

and after some time get result from db

db logs has errors:

2017-04-08 23:13:04 EEST —:  could not reserve shared memory region (addr=00000000022D0000) for child 00000000000016B0: error code 487
2017-04-08 23:13:04 EEST —:  could not fork autovacuum worker process: No error

How to solve this problem?



via Sergei R

No comments:

Post a Comment