2

I found our Node services intercommunication (using request) will occationally report this error:

Error: Parse Error
at socketOnEnd (_http_server.js:455:20)
at Socket.emit (events.js:203:15)
at Socket.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

After some digging in _http_server.js, it turns out to be the http parser finish error. It means that util the socket close, the http parser cant correctly parse the http request.

Our service log shows that its the client timeout and close the socket and then the server report this error. So I doubt that it's this request issue cause the problem, but I have no further evidence.

Another question is why the Node server receiving a bad http request not aborting the parse phase and response with an error immediately but hanging there until the client timeout and close the socket?

Is anyone reaching the same problem?

p.s.

Using Node version: 10.16.0

1 Answer 1

2

After logging the socket data, I found the malformed http request. It's missing the body:

POST /internals/topics/list HTTP/1.1\r\ncontent-type: application/json\r\nx-client-host: production/user-service-5d76d998d8-wr9ws\r\nHost: topic-service.prod:3000\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\ncontent-length: 117\r\nnewrelic:xxx\r\nConnection: close\r\n\r\n

So this really is a request package problem and it's not maintained anymore, I am going to use got package instead.

Hope it helpful for others who reach the same problem.

Sign up to request clarification or add additional context in comments.

1 Comment

how did you log the socket data? I am using a third party framework that runs on top of koa and I get the same error occasionally in the logs. I don't know what requests cause this error and I wanted to debug it. I wanted to log the http requests that cause this error but not sure how to do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.