|
1 | 1 | 'use strict'
|
2 | 2 |
|
3 |
| -const assert = require('assert').strict |
| 3 | +const assert = require('assert') |
4 | 4 | const crypto = require('crypto')
|
5 | 5 | const http = require('http')
|
6 | 6 | const https = require('https')
|
@@ -645,14 +645,12 @@ function getChoppedStreamHandler (client, onerror) {
|
645 | 645 | // There was an error: clean up resources.
|
646 | 646 | //
|
647 | 647 | // Note that in Node v8, destroying the gzip stream results in it
|
648 |
| - // erroring with the following. No harm, however. |
| 648 | + // emitting an "error" event as follows. No harm, however. |
649 | 649 | // Error: gzip stream error: zlib binding closed
|
650 | 650 | // at Gzip._transform (zlib.js:369:15)
|
651 | 651 | // ...
|
652 | 652 | destroyStream(gzipStream)
|
653 |
| - if (!completedFromPart['intakeReq']) { // eslint-disable-line dot-notation |
654 |
| - intakeReq.destroy() |
655 |
| - } |
| 653 | + intakeReq.destroy() |
656 | 654 | }
|
657 | 655 |
|
658 | 656 | client.sent = client._received
|
@@ -752,6 +750,10 @@ function getChoppedStreamHandler (client, onerror) {
|
752 | 750 | if (intakeRes.statusCode === SUCCESS_STATUS_CODE) {
|
753 | 751 | err = new Error(`premature apm-server response with statusCode=${intakeRes.statusCode}`)
|
754 | 752 | }
|
| 753 | + // There is no point (though no harm) in sending more data to the APM |
| 754 | + // server. In case reading the error response body takes a while, pause |
| 755 | + // the gzip stream until it is destroyed in `completePart()`. |
| 756 | + gzipStream.pause() |
755 | 757 | }
|
756 | 758 |
|
757 | 759 | // Handle events on the intake response.
|
|
0 commit comments