Conversation
|
This looks nice! Will respond to your questions hopefully tomorrow. Some preliminary feedback is that I think it might be worth sorting out the uncovered lines adjacent to these functions, and either adding tests for them or getting really confident that they aren't reachable. Probably that can be done in a separate PR that goes in before this one. The most important reason to get coverage to or near 100% is that it reduces the chance of breaking things when we refactor. The other reason is that asserting 100% coverage means we won't inadvertently pull in new code paths that are untested, or leave unused code paths after refactoring. |
7993012 to
0382de0
Compare
|
All the touched lines have 100% coverage, but Coveralls is complaining because the total number of lines in the lib was reduced a bit, increasing the uncovered percentage. |
This check is no longer reachable because `util.promisfy` will ignore subsequent calls to the callback method.
c3ba427 to
16c9c23
Compare
|
Went with Option B instead. |
This is a POC for #1557.
Besides adding the extra functionality, I think it cleans up the massive function
.end()a little. It removes the need forcontinueWithResponseBodyto have an error first signature.The area where I question this logic is around error handling, but this has roots in the current code. My question is, what should happen to errors from inside user provided reply functions?
Current logic:
Throw an error without accepting a callback arg
Throw an error with accepting a callback arg
Passing an error to the callback
With proposed logic
New use case: throw an error inside an async function (or return a rejecting promise)
So it's kinda the same 🤷♂. I wish all these scenarios did one or the other.
In general, I question why we sometimes want errors to result in valid responses with 500 status codes, instead of letting the user defined function catch errors and return the 500 manually. But that might be out of scope for this topic and I'm overthinking it.