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

Error accessing request.promster.start in hapi #150

Closed
2color opened this issue Jun 5, 2019 · 4 comments
Closed

Error accessing request.promster.start in hapi #150

2color opened this issue Jun 5, 2019 · 4 comments

Comments

@2color
Copy link

2color commented Jun 5, 2019

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Given a server as follows:
  import { createPlugin } from '@promster/hapi'
  import { createServer as createMetricsServer } from '@promster/server'
  import Hapi from '@hapi/hapi'

  const server = Hapi.server({
    port: 4000,
    host: process.env.HOST,
  })

  await server.register(createPlugin())

  server.route({
    method: 'GET',
    path: '/',
    handler: (request, h) => {
      return 'hello!'
    }
  })

  await server.start()
  console.log('Server running on %s', server.info.uri)

  await createMetricsServer({ port: 4001 })
  console.log(`@promster/server started on port ${process.env.METRICS_PORT}.`)

  await server.register(createPlugin())
  1. Then 'curl localhost:4000'
TypeError: Cannot read property 'start' of undefined
    at Object.onResponseHandler [as listener] (/...../myserver/node_modules/@promster/hapi/modules/plugin/plugin.js:54:40)

Expected behavior

  • No error and request.promster available in onResponseHandler

Additional context

Plugin-specific state. Provides a place to store and pass request-level plugin data. The

  • Strangely, when debugging, the onRequestHandler wouldn't get called on incoming requests.
@tdeekens
Copy link
Owner

tdeekens commented Jun 5, 2019

Thanks for the very nice but report and sorry for the inconvienence. I will try to look into this as soon as I find time.

@tdeekens
Copy link
Owner

tdeekens commented Jun 5, 2019

Turns on server.events.on('request') is only invoked when logging before. There is a GitHub issue where people got confused. Loads of the other internal events are not supported anymore. I went back to use server.ext tested it locally and will publish soon.

@tdeekens
Copy link
Owner

tdeekens commented Jun 5, 2019

Published @promster/hapi@2.2.5 and tested it locally. Please re-test and feel free to re-open in case it's not solved. Thanks again.

@tdeekens tdeekens closed this as completed Jun 5, 2019
@2color
Copy link
Author

2color commented Jun 6, 2019

Thanks. Works like a breeze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants