Skip to content

Commit

Permalink
fix(@angular/cli): process keeps running when analytics are enabled
Browse files Browse the repository at this point in the history
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

(cherry picked from commit c0a0f72)
  • Loading branch information
alan-agius4 authored and clydin committed Apr 18, 2023
1 parent d9e9f74 commit f4a6dac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/angular/cli/src/analytics/analytics-collector.ts
Expand Up @@ -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}.`),
Expand Down

0 comments on commit f4a6dac

Please sign in to comment.