dwyl / hapi-postgres-connection

:zap: Creates a PostgreSQL Connection (Pool) available anywhere in your Hapi App
GNU General Public License v2.0
40 stars 13 forks source link

prevent route from hanging by *always* closing the pg connection #10

Closed nelsonic closed 8 years ago

nelsonic commented 8 years ago

when a route does not make any queries to postgres, do we still need to close the db connection?

this was noted by @Conorc1000 in: https://github.com/OxfordAbstracts/application/issues/197

nelsonic commented 8 years ago

Add these 3 lines to index.js

  server.ext('onPostHandler', function (request, reply) {
    request.pg && request.pg.done && request.pg.done();
    reply.continue();
  })

suggested by @rjmk

nelsonic commented 8 years ago

trying it now.

nelsonic commented 8 years ago

Seeing the following error when running this:

Debug: internal, implementation, error
    Error: write EPIPE
    at Object.exports._errnoException (util.js:874:11)
    at exports._exceptionWithHostPort (util.js:897:20)
    at WriteWrap.afterWrite (net.js:763:14)
nelsonic commented 8 years ago

@rjmk I think I may have found a simpler solution... :wink: