stream-utils / raw-body

Get and validate the raw body of a readable stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

readStream method and the aborted stream event

jpreese opened this issue · comments

We were unable to find how the aborted event was being raised. According to https://nodejs.org/api/stream.html no such event exists. I also couldn't find any other reference to it in the code base.

Everytime we POST data, raw-body just hangs and eventually times out with an aborted error. Even if we're posting a very minimal amount of data.

The aborted event is raised by Node.js here: https://github.com/nodejs/node/blob/4e6dc00401f6ca619c1bdb82394d2ba1674b5867/lib/_http_server.js#L280

Why they do not document I can't tell you :) I believe that if you removed that listener, our tests would no longer pass, so we should be asserting it raises.

Why your code hangs I can't really say, either. Can you provide some information to help us reproduce the hang?

Thanks for the quick response. I'm away from my desk at the moment, so I'll get some code snippets together when I return.

Though off the top of my head, it's getting into readStream, attaches to the events (aborted, data, etc), and then just hangs until the web server returns a 504. So we actually never see the aborted error code returned -- only through the debugger.

After the 504, the aborted, done, and cleanup events are raised.

The length of the request, for testing, is around 80. The received value is always 0.

If it gets into this module and there are no data events raised, are you sure you don't have something reading the steam before this module? A stream in Node.js can only be read once, so if it is read prior to this module, you'd see pretty much exactly what you are describing.

That would be it. We rearranged the order in which requests go through the pipeline and it's not hanging anymore.

Thanks again for the responses!

Awesome, it was no problem to help!