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

Failed to get `request.response` object from 'response' event #3825

Closed
chunfengd opened this Issue Sep 21, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@chunfengd

chunfengd commented Sep 21, 2018

Is this a security related issue?

No

What are you trying to achieve or the steps to reproduce?

When I listen on the response event, the request.response is always null. This happens in version 17.5.4, but not in 17.5.2.

const server = Hapi.server({
  port: 8080,
});

server.route({
  method: 'GET',
  path: '/echo',
  handler: request => {
    return Object.keys(request);
  },
});

server.events.on('response', request => {
  console.log(
    request.info.remoteAddress +
      ': ' +
      request.method.toUpperCase() +
      ' ' +
      request.url.path +
      ' --> ' +
      (request.response && request.response.statusCode) // request.response is always null
  );
  if (request.response && request.response._error) {
    console.log(request.response._error);
  }
});

server.start()

What was the result you received?

request.response is always null

What did you expect?

I expect to get the response object from the event callback

Context

  • node version:10.6.0
  • hapi version: 17.5.4
  • os: alpine (I run the code in a node:alpine docker container)
  • any other relevant information:

@hueniverse hueniverse self-assigned this Sep 23, 2018

@hueniverse

This comment has been minimized.

Member

hueniverse commented Sep 23, 2018

Cannot reproduce.

@Aex

This comment has been minimized.

Aex commented Oct 8, 2018

We have been running into the same issue. We are using hapi version: 17.6. We noticed that it had something to do with the version of node we were using. We were running node version: 10.2.1. We also noted an issue running node version: 10.6.0.

Not sure what the root cause is, but we reported success with node version 8.12.0 and 10.10.0.

@kminehart

This comment has been minimized.

kminehart commented Dec 6, 2018

@Aex confirmed, was having issues on node 11.3.0.

Switched to 10.10.0 and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment