New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit FormData error events as Request error events #1341
Conversation
The tests pass when I run them locally, looks like something is up with Travis? |
@rwky I think any error emitted from combined-stream/form-data would do it, not necessarily ECONNRESET |
@simov would you be happy merging this in if I added tests? I can rummage through form-data and see if there's an error I can trigger easily. |
First of all I forgot to thank you for the thorough description of that task. Personally I don't think re-emitting the form-data errors there would do any harm, because we're not adding any opinion to it. As for the test it is needed just to state that this behavior is expected, also the Travis build should pass, no idea what's the problem. |
It would be nice to have a test for this, but if it's too hard then we'll take it without one. The Travis failure appears to be because the Travis network has exceeded its GitHub request limit for the day. I'll rerun the build again tomorrow. |
Still getting that same Travis failure. It's not a problem with this PR. I'll address this in a separate issue and try to get the person who submitted our browser tests involved. @rwky have you had a chance to further look into a test case? |
I've added a simple test case, fortunately form-data has an easy way of generating an error by passing an array as a value to the append method. Looks like Travis is behaving again 😄 |
Looking good to me, besides the port number. |
I copied the url from the form-data tests, it never gets called since the error is generated before request sends any data. |
@rwky re your latest comment, we're in the process of standardizing test ports to 6767, and the Can you cherry-pick this commit into this PR: nylen/request@d6bf426 |
@nylen looks good to me I've cherry picked that commit. |
Okay then. I'll merge this tomorrow if no one objects or beats me to it. Thanks for contributing and for following up. |
No worries happy to help. Do you have an idea when it will land in NPM? |
I'd like to get #1344 in before a new release too. are you good with waiting at most a week for that to land? |
Yep I'm happy to wait, no rush I'm currently using git+https url in package.json from my own repo so it's not a problem, just like to know when I can check back to switch to the official package. |
👍 I'll let you know when it's out. |
Emit FormData error events as Request error events
@rwky version |
@nylen Excellent thanks! |
As per #1336 created a clean request which passes tests.
Below is a stack trace (from 1st October 2014 sorry it's old!) caused by uploading an image to the Facebook API using request. The trace is caught by a node domain otherwise it'd be ignored.
As you can see there is an ECONNRESET in combined_stream which is passed up to the form-data module, however this error is not then passed up to request, unless domains are in place it is just lost.
This change will pass the error up to request so users can act on the 'error' event, in my case I'd retry the request. The only impact this should have on existing applications is they emit error events more often if the application uses form-data instead of ignoring it.
The alternative option would be to in the application would be to listen to the 'error' event on the form object created from request.form() which I'm happy to do but I thought since it's used by request it'd be good if it could be sent to the callback.
I would write a test case for it but I've no idea how to trigger an ECONNRESET in combine_stream intentionally, if anyone knows how I'll gladly write a test case!