Repository navigation
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
21.2.13 (@angular/build 21.2.13). Bisected — it first appears in 21.2.14.
Description
When two or more components declare an inline styles whose content is byte-identical, ng build finishes the bundle correctly — it prints Application bundle generation complete and writes a complete dist/ — and then the process never exits. It hangs forever and has to be killed.
The output looks like a completely successful build, which makes this deceptive: locally it looks like the build "is slow", and in CI the job hangs until the runner limit. In our case a GitHub Actions job sat in the Compilar step for 1h30m before we cancelled it, against the 1m18s the same job took before the offending commit landed. Neither lint nor unit tests catch it, because both exit normally — only ng build hangs.
Exactly one active handle is left behind when the build is done: the ChildProcess of the esbuild service, still killed: false. With that handle open, Node's event loop never drains:
=== ACTIVE HANDLES (1): ["ChildProcess"]
=== ACTIVE REQUESTS (0): []
ChildProcess spawnfile= .../node_modules/@esbuild/darwin-arm64/bin/esbuild pid= 6806 killed= false
Captured by running the build with NODE_OPTIONS="--require ./handles.js", where handles.js is:
setTimeout(() => {
console.error('=== ACTIVE HANDLES:', process._getActiveHandles().map(h => h.constructor.name));
console.error('=== ACTIVE REQUESTS:', process._getActiveRequests().map(r => r.constructor.name));
}, 30000).unref();A sample of the hung process shows the main thread parked in uv__io_poll / kevent over LibuvStreamWrap handles, consistent with the un-closed pipe to that child.
Minimal reproduction of the problem with instructions
Reproduced on a brand-new workspace — no third-party dependencies involved:
npx @angular/cli@21.2.19 new repro --defaults --skip-git --style=css --ssr=false
cd reproAdd src/app/dup.ts:
import { Component } from '@angular/core';
const CSS = `:host { display: inline-flex; }`;
@Component({ selector: 'app-dup-a', template: `<i></i>`, styles: CSS })
export class DupA {}
@Component({ selector: 'app-dup-b', template: `<i></i>`, styles: CSS })
export class DupB {}Reference both from src/app/app.ts so they enter the compilation graph:
import { DupA, DupB } from './dup';
// ...
imports: [RouterOutlet, DupA, DupB],Then:
npm run buildThe bundle is generated and the process hangs. It has to be killed.
Results, all on the same workspace and the same node_modules:
| Variant | Bundle | Process exits |
|---|---|---|
| Fresh app, untouched | ✅ | ✅ exit 0, ~5s |
Two components, identical inline styles |
✅ | ❌ never |
Same, but second one is styles: CSS + ' ' (one space) |
✅ | ✅ exit 0, ~2s |
Two components sharing the same file via styleUrl |
✅ | ✅ exit 0, ~2s |
Two things worth highlighting from that table:
- A single whitespace character is the difference between a 6-second build and an infinite hang.
styleUrlis not affected. Only inlinestyleswith identical content triggers it, which suggests the inline-stylesheet path is keyed by content somewhere the shared-file path is not.
Two components is enough; it is not specific to a larger number.
Bisection: introduced in 21.2.14
I bisected with the same dup.ts in each workspace, pinning every @angular/* package to an exact version (note that npx @angular/cli@21.0 new still resolves ^21.0.0 to the latest 21.2.x, so the versions have to be pinned explicitly):
@angular/build |
esbuild | Process exits |
|---|---|---|
| 20.3.34 | 0.28.1 | ✅ ~2s |
| 21.0.6 | 0.26.0 | ✅ ~2s |
| 21.1.5 | 0.27.2 | ✅ ~4s |
| 21.2.0 | 0.27.3 | ✅ ~4s |
| 21.2.10 | 0.27.3 | ✅ ~4s |
| 21.2.12 | 0.27.3 | ✅ ~4s |
| 21.2.13 | 0.27.3 | ✅ ~4s |
| 21.2.14 | 0.27.3 | ❌ hangs |
| 21.2.21 | 0.28.1 | ❌ hangs |
It is not the esbuild version. Three independent checks:
- 21.2.13 and 21.2.14 ship the same esbuild, 0.27.3 — one hangs, the other does not.
@angular/build20.3.34 runs esbuild 0.28.1, the newest of the set, and does not hang.- Forcing esbuild back to 0.27.2 under
@angular/build21.2.21 (npmoverrides) still hangs.
The only @angular/build change in the 21.2.14 release is commit d46c082fb — "fix(@angular/build): prevent esbuild service child process leakage", which fixed #33201, whose symptom was described as "the hosting Node.js process remains alive after build completion".
That commit switched single builds to a scoped esbuild.context() and wrapped runEsBuildBuildAction in try/finally with a state flag, to "guarantee accurate tracking and clean disposal of all internal esbuild service child processes". It touched build-action.ts and bundler-context.ts.
So this looks like that fix not covering one case: when two components carry byte-identical inline styles, the stylesheet bundling path appears to end up with a context that the new tracking does not dispose — leaving behind exactly the kind of child process the commit set out to eliminate, and reintroducing #33201's symptom for a narrower input. The fact that identical content is required (one space of difference is enough to avoid it), while a shared styleUrl file is unaffected, points at something keyed by stylesheet content in that path.
Exception or Error
No exception. That is the core of the problem — the build reports full success and then never returns:
Application bundle generation complete. [5.097 seconds]
Output location: /path/to/repro/dist/repro
<process hangs here indefinitely>
Your Environment
Angular CLI : 21.2.19
Angular : 21.2.19
Node.js : 24.14.0
Package Manager : npm 11.9.0
Operating System : darwin arm64 (macOS 26.5.2)
@angular/build : 21.2.19
esbuild : 0.28.1
typescript : 5.9.3
Also reproduced on a fresh @angular/cli@21.2.19 workspace and on pinned 21.2.14 / 21.2.21 workspaces, as listed in the bisection table.
Anything else relevant?
Not platform-specific. Everything above was measured on macOS/arm64 with Node 24, but the same commit hung our GitHub Actions job on ubuntu-latest with Node 22, so it reproduces on Linux too.
Only ng build is affected. The unit-test builder (ng test, @angular/build:unit-test with Vitest) completes and exits normally on the very same code, as does ng lint.
How we hit it. Four small icon components legitimately shared one CSS constant (styles: SHARED_ICON_STYLES) — a normal way to avoid repeating identical CSS. That is all it took. We worked around it by moving the shared CSS into the global stylesheet so it exists only once, but the natural fixes a developer reaches for first — extracting a shared constant, or copy-pasting the same block — are precisely what triggers the hang.
Suggested severity. The failure mode is quiet and expensive: no error message, a build that looks successful, and a CI job that burns runner minutes up to the platform limit rather than failing fast. Anyone hitting this without knowing the cause will look for the problem in their application code, since the build output gives no reason to suspect the process itself.
Activity
alan-agius4 commentedon Aug 21, 2026
Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem.
If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use
ng new repro-appto create a new project where you reproduce the problem.angular-automatic-lock-bot commentedon Oct 19, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.