Title: @angular/build: leaves esbuild service child alive after watch:false build · Issue #33201 · angular/angular-cli · GitHub
Open Graph Title: @angular/build: leaves esbuild service child alive after watch:false build · Issue #33201 · angular/angular-cli
X Title: @angular/build: leaves esbuild service child alive after watch:false build · Issue #33201 · angular/angular-cli
Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Symptom: After a one-shot ng build (no --watch) completes succ...
Open Graph Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Symptom: After a one-s...
X Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Symptom: After a one-s...
Opengraph URL: https://github.com/angular/angular-cli/issues/33201
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@angular/build: leaves esbuild service child alive after watch:false build","articleBody":"### Command\n\nbuild\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\n**Symptom**: After a one-shot ng build (no --watch) completes successfully, the Node process does not exit. `process._getActiveHandles()` shows a ChildProcess for the esbuild service\n```\nall services stopped\nhandles: [ 'WriteStream', 'WriteStream', 'ReadStream', 'ChildProcess' ]\nrequests: []\nchild: {\n pid: 52715,\n file: '/my/machine/\u003cproject\u003e/node_modules/.pnpm/@esbuild+linux-x64@0.27.3/node_modules/@esbuild/linux-x64/bin/esbuild',\n args: [\n '/my/machine/\u003cproject\u003e/node_modules/.pnpm/@esbuild+linux-x64@0.27.3/node_modules/@esbuild/linux-x64/bin/esbuild',\n '--service=0.27.3',\n '--ping'\n ]\n}\n```\nThe root cause lays in @angular/build/src/builders/application/build-action.js — `runEsBuildBuildAction`:\n\n - For `watch:false`, `BundlerContext.incremental` is `false`, so the build path uses one-shot `esbuild.build()` and never creates an `esbuild.context()`.\n - `ExecutionResult.dispose()` → `BundlerContext.dispose()` only awaits `this.#esbuildContext?.dispose()`, which is `undefined` in this path. So nothing tears down esbuild's long-lived\n service child.\n - The builder never calls `esbuild.stop()` anywhere.\n - The plugin teardown registered via `build.onDispose(...)` in compiler-plugin.js (`javascriptTransformer.close(), cacheStore?.close(), compilation.close?.()`) is fire-and-forget\n (void ...) and scheduled by esbuild via `setTimeout(cb, 0)`, so it can race with the function returning.\n\nThe issue is not apparent in regular builds since the process is exited after the build loop marks `done: true` but builders that decorate over the Angular builder inherit the leakage. \n\n\n### Minimal Reproduction\n\nHere's how we use the internal builder programatically: https://github.com/native-federation/angular-adapter/blob/8bd8b58b7db8ae3cac5818c2d643077a8b3161ce/packages/angular/src/builders/build/builder.ts#L95\n\n### Exception or Error\n\n```text\n\n```\n\n### Your Environment\n\n```text\n\u003e ng version\n\n\n _ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\n |___/\n \n\nAngular CLI : 21.2.10\nAngular : 21.2.12\nNode.js : 24.11.1\nPackage Manager : pnpm 10.33.0\nOperating System : linux x64\n\n┌───────────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────────┼───────────────────┼───────────────────┤\n│ @angular-devkit/build-angular │ 21.2.10 │ ^21.2.10 │\n│ @angular/build │ 21.2.10 │ ^21.2.10 │\n│ @angular/cli │ 21.2.10 │ ^21.2.10 │\n│ @angular/common │ 21.2.12 │ ^21.2.0 │\n│ @angular/compiler │ 21.2.12 │ ^21.2.0 │\n│ @angular/compiler-cli │ 21.2.12 │ ^21.2.0 │\n│ @angular/core │ 21.2.12 │ ^21.2.0 │\n│ @angular/forms │ 21.2.12 │ ^21.2.0 │\n│ @angular/platform-browser │ 21.2.12 │ ^21.2.0 │\n│ @angular/router │ 21.2.12 │ ^21.2.0 │\n│ rxjs │ 7.8.2 │ ~7.8.0 │\n│ typescript │ 5.9.3 │ ~5.9.2 │\n│ vitest │ 4.1.5 │ ^4.0.8 │\n└───────────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else relevant?\n\nThis is only happening when the buildAction is called programatically","author":{"url":"https://github.com/Aukevanoost","@type":"Person","name":"Aukevanoost"},"datePublished":"2026-05-14T06:54:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/33201/angular-cli/issues/33201"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:30d02261-9860-b8c9-a3a1-532c417135c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C850:385126:3873DF:5178A0:6A636AFA |
| html-safe-nonce | 6cad1bebd59dcd34d2b8d29a2e7074ec140de0754405fd2b5db59e6d908df534 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODUwOjM4NTEyNjozODczREY6NTE3OEEwOjZBNjM2QUZBIiwidmlzaXRvcl9pZCI6IjI5NTc0MjkxNzA4NzUwOTk4OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 423d50d004068c1d4b04fd818f0177f5b92e2ccd509a39af5b818f7c2346a612 |
| hovercard-subject-tag | issue:4443888354 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33201/issue_layout |
| twitter:image | https://opengraph.githubassets.com/791555e315c86897ebed2f065a6e62a843883a6aa7f6fb6f5166f0a37284ee78/angular/angular-cli/issues/33201 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/791555e315c86897ebed2f065a6e62a843883a6aa7f6fb6f5166f0a37284ee78/angular/angular-cli/issues/33201 |
| og:image:alt | Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Symptom: After a one-s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Aukevanoost |
| hostname | github.com |
| expected-hostname | github.com |
| None | e7b5617850fbcd6d10fe2b7c56398444bccb5f3a58a4a18c6d363971295bcd03 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | aa341b3f432dc63fa9633042725aec601722a352 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width