hapijs / good

hapi process monitoring
Other
525 stars 160 forks source link

Cannot read property 'statusCodes' of undefined #597

Closed cgatesman closed 5 years ago

cgatesman commented 5 years ago

hapi: 17.5.4 good: 8.1.1 good-squeeze: 5.1.0

My application crashes with an unhandled promise rejection when using good along with a takeover redirect in a onRequest.

Although I'm not using it, a simple example of this is to use hapi-require-https and don't setup https:

server.register({
  plugin: require('hapi-require-https'),
  options: {
    proxy: false
  }
});

My current good configuration is as follows, but it doesn't seem to matter how simple I make it. The crash always occurs:

  await server.register({
    plugin: require('good'),
    options: {
      ops: {
        interval: 1000
      },
      reporters: {
        myConsoleReporter: [
          {
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{log: '*', response: '*'}]
          },
          {
            module: 'good-console'
          },
          'stdout'
        ]
      }
    }
  });

With this setup, when you hit your application using http, it crashes with an unhandled promise rejection when it tries to redirect (301) to https:

SEVERE: Unhandled promise rejection!
Promise: Promise {
  <rejected> TypeError: Cannot read property 'statusCodes' of undefined
    at Network._server.events.on (/Users/chad/development/np-pillars/node_modules/oppsy/lib/network.js:56:38)
    at module.exports.internals.Podium.internals.Podium.emit (/Users/chad/development/np-pillars/node_modules/podium/lib/index.js:220:49)
    at Request._finalize (/Users/chad/development/np-pillars/node_modules/hapi/lib/request.js:388:27)
    at Request._reply (/Users/chad/development/np-pillars/node_modules/hapi/lib/request.js:350:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7) } 
cgatesman commented 5 years ago

Further investigating, this appears to be an issue in oppsy. As a workaround, I am able to turn it off with ops: false. I will create an Issue in the oppsy project.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.