(result)
| 766 | } |
| 767 | |
| 768 | function onRead (result) { |
| 769 | if (result.done) { |
| 770 | sourceOpen = false |
| 771 | sendTrailer(null, res, reply) |
| 772 | return |
| 773 | } |
| 774 | /* c8 ignore next 5 - race condition: eos handler typically fires first */ |
| 775 | if (res.destroyed) { |
| 776 | sourceOpen = false |
| 777 | reader.cancel().catch(noop) |
| 778 | return |
| 779 | } |
| 780 | const shouldContinue = res.write(result.value) |
| 781 | if (shouldContinue === false) { |
| 782 | waitingDrain = true |
| 783 | res.once('drain', onDrain) |
| 784 | return |
| 785 | } |
| 786 | reader.read().then(onRead, onReadError) |
| 787 | } |
| 788 | |
| 789 | function onDrain () { |
| 790 | if (!waitingDrain || !sourceOpen || res.destroyed) { |
nothing calls this directly
no test coverage detected