SimonDegraeve / hapi-graphql

Create a GraphQL HTTP server with Hapi.
115 stars 27 forks source link

request.payload=IncomingMessage when logging request payload with good-squeeze #20

Closed pingvinen closed 7 years ago

pingvinen commented 7 years ago

I have run into a weird issue, and I am hoping that someone can help me figure it out.

Minimal project showing the issue

For debugging purposes, I am running hapi with good logging where I am including logs of response events including the request payload. This works just fine except when used in combination with hapi-graphql, where request.payload is mapped to the IncomingMessage instance, which has a lot of circular references meaning that the server can end up in an infinite loop killing the poor node process handling it.

pingvinen commented 7 years ago

This seems to be related to (or triggered by) the handler.defaults setting the payload to a stream. Bypassing it or changing it to data, makes the logging work, but makes parsePayload resolve with an empty object, triggering a validation error.

pingvinen commented 7 years ago

Tried adding an endpoint to my test project, where I change the payload to be a stream. This messes up the logging as well, so I guess this is actually an issue for the logging part of Hapijs.