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
Error on initialization should prevent actual HTTP request from being sent #1880
Conversation
Hey, @arcana261, very good work on this PR 👍 However I'm proposing a slightly simpler solution here: simov@6931cea Basically you need only the Unfortunately even this doesn't cover all possible cases, and our error handling is kind of awkward due to the way the module is being initialized. You can read about it here: #1558 Still I think that aboring on line 284 is slightly better for this particular case, because it says Let me know what do you think. |
Dear good Sir @simov. Sorry for replying so late... (holidays in my country!) I think it is smart... I'm just sorry for missing the
I would definitely say this will not cover all our errors but I think we are making an improvement here 👍 Of course we are not expected to put a big |
Providing a callback is optional, and having one means that the response will be buffered into memory - not something that you want to have by default. Also I don't want to have the No idea why you used the As for the Happy holidays! 🎉 |
Ahh I see... Thank you for your patient response. So we need to Thanks! 😊 |
re:
I don't understand your question. What I'm suggesting is to merge my last commit on top of yours. Quoting the relevant bits from my previous comment:
|
Ok... Thanks! I appreciate it 😄 |
👍 |
Hello
Working on a propitiatory piece of app the other day, I ran into a strange exception happening on nextTick. This exception would complain of can not call method request of undefined. When I inspected the problem deeply I understood the problem was that the URI which I passed to request did not have any protocol defined, like /bad-uri but also the problem seemed to be triggered because a stream was piped to request to upload some files to a WebDAV server. I also confirmed that request did in fact call my callback with provided exception error but was still trying to make the actual HTTP request regardless. The exception happened because initialization was failed thus leaving undefined variables behind but this case of error was never checked in Request.write method which was called in nextTick following stream of data from my file. So I tried to fix this problem by:
The following is an image showing the stacktrace of exception which I'm talking about: