Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hapi example does not complete Hapi request lifecycle #1062

Closed
sfhardman opened this issue Feb 10, 2017 · 1 comment
Closed

Hapi example does not complete Hapi request lifecycle #1062

sfhardman opened this issue Feb 10, 2017 · 1 comment

Comments

@sfhardman
Copy link
Contributor

The Hapi example (examples/custom-server-hapi) does not complete the Hapi lifecycle for requests handled by defaultHandlerWrapper.

To reproduce the issue edit examples/custom-server-hapi/server.js as per below. Requests to /a and /b are logged to the console, but requests to / are not logged. Pull request to come...

const next = require('next')
const Hapi = require('hapi')
const Good = require('good');
const { pathWrapper, defaultHandlerWrapper } = require('./next-wrapper')

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const server = new Hapi.Server()

// add request logging (optional)
const pluginOptions = [
  {
    register: Good,
    options: {
      reporters: {
        console: [{
          module: 'good-squeeze',
          name: 'Squeeze',
          args: [{
            response: '*',
            log: '*'
          }]
        }, {
          module: 'good-console'
        }, 'stdout']
      }
    }
  }
]

app.prepare()
.then(() => {
  server.connection({ port: 3000 })
  server.register(pluginOptions)
  .then(() => {
    server.route({
      method: 'GET',
      path: '/a',
      handler: pathWrapper(app, '/a')
    })

    server.route({
      method: 'GET',
      path: '/b',
      handler: pathWrapper(app, '/b')
    })

    server.route({
      method: 'GET',
      path: '/{p*}', /* catch all route */
      handler: defaultHandlerWrapper(app)
    })

    server.start().catch(error => {
      console.log('Error starting server')
      console.log(error)
    }).then(() => {
      console.log('> Ready on http://localhost:3000')
    })
  })
})
@sfhardman
Copy link
Contributor Author

Resolved by PR #1099

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant