Failed to get `request.response` object from 'response' event
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:
Cannot reproduce.
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.
@Aex confirmed, was having issues on node 11.3.0.
Switched to 10.10.0 and it worked.
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.