fix(@angular/cli): process keeps running when analytics are enabled

In newer Node.js versions ng commands do not terminate properly when analytics are enabled.

This is because the request is never closed unless a `data` event listener is attached.

Closes #25034 and closes #25008
This commit is contained in:
Alan Agius 2023-04-18 17:29:49 +00:00 committed by angular-robot[bot]
parent 758b0695f3
commit c0a0f727f8

View File

@ -182,6 +182,9 @@ export class AnalyticsCollector {
},
},
(response) => {
// The below is needed as otherwise the response will never close which will cause the CLI not to terminate.
response.on('data', () => {});
if (response.statusCode !== 200 && response.statusCode !== 204) {
reject(
new Error(`Analytics reporting failed with status code: ${response.statusCode}.`),