Commit de46572
fix: avoid spurious unhandledRejection when transport fails mid-sendRequest
If the transport fails (or #receive observes stream closure) while sendRequest is awaiting #sendMessage, #close() rejects the response promise before the caller's await has attached a handler. Node then reports a spurious unhandledRejection (followed by PromiseRejectionHandledWarning), even though the caller's await does observe the rejection.
Attach a noop .catch to responsePromise so the rejection is considered handled at the time it's raised. The rejection is still delivered to the caller verbatim via 'return responsePromise'.1 parent c6e6ee2 commit de46572
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
1471 | 1479 | | |
1472 | 1480 | | |
1473 | 1481 | | |
| |||
0 commit comments