Closed pimterry closed 3 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/request.js | 16 | 17 | 94.12% | ||
<!-- | Total: | 16 | 17 | 94.12% | --> |
Totals | |
---|---|
Change from base Build 83: | 0.3% |
Covered Lines: | 350 |
Relevant Lines: | 408 |
Using the test from @stefan-guggisberg's PR (#28), this implementation adds support for reporting initial connection errors, so that the test passes.
This fixes #27 (at least for the initial connection error case - I'm not 100% sure that all possible errors after the initial connection are correctly handled, but I haven't seen any obvious issues).
Without this change, initial request errors (any connection that fails before identification is complete) crash the node process completely!
The implementation here:
emitError
function to client requests. It's the same asclientRequest.emit('error')
, except it also works if you call it before the initial request is set up (i.e. beforetake(request)
has been called).identifyConnection
, and then adds an error parameter to the callback there and inholdConnectionToIdentification
to pass any errors back.ClientRequest.emitError(error)
inhandleClientRequest
, if theholdConnectionToIdentification
call there fails.