Open chrisegner opened 7 years ago
Could you take a look, @osher ?
I should probably clarify that, from the client side, this may cause a connection reset. We detected this when our test for our api spec endpoint returned ECONNRESET. It's possible a smaller document might have gotten out before the server crashed (I'm not super familiar the the internal details of the express and http modules' buffering schemes). For reference, our spec was 36k as yaml, 51k as json (endpoint serves json).
@chrisegner - if you say that with a shorter yaml it works while with a heavier yaml it doesnt - it's a score for the buffer theory. I know that my end-to-end tests pass - however, they do work with a rather short spec doc. I'll be in the office tomorrow (I'm in GMT+2), and will be able to run some tests. I'll keep you updated with my findings as soon as I have any
@chrisegner - man, I need help to reproduce. I've constructed an e2e test with a huge doc (over 100K), and did not encounter the bug.
can you please help provide a reproduction scenario?
If it helps, you can see what I've done here: https://github.com/theganyo/swagger-node-runner/pull/82
which is basically, raise a connect server with a document I inflated with a #definition/veryVeryBigCompoundType
as a type with 200 string fields with a lorem-ipsum description (specifically 'content-length': '125454'
for yaml, and a similar magnitude for json)
I could retrieve the doc both as yaml and as json
@chrisegner - can you help me reproduce? maybe it's framework-dependent? could there be a collision with a middleware you're using? I would like to learn about it and solve it
@chrisegner - what framework are you using? could it have any relation to Accept-Encoding: gzip
? I may have found something, I need a little help from you to determine if what I found is relevant to your case or on another area
could also have to do with https://github.com/theganyo/swagger-node-runner/issues/87 since he is using connect middleware
I think the intention of that commit should be to put a return statement in the if and remove else but the first didn't happen going to do a pull request for this. I hope it's getting released soon
If you use a swagger_raw pipe to send out the swagger spec when mediated by connect_middleware, the request processing continues after the response has been sent. This eventually leads to express's default 404 handler kicking in, which in turn produces an error when it attempts to set the status code header for a response that has already been sent.
Specifically, the commit ac6dad9fb5071bddd7a95c32cc38e9cc15c57228 needs to be reverted. It's not clear what problem it's attempting to solve, so I can't say what the impact is, but whatever it's trying to do, this manner of doing it breaks express's contact.
Stack trace: