René's URL Explorer Experiment


Title: @angular/build:unit-test hangs forever when two components in one file have identical inline styles · Issue #33317 · angular/angular-cli · GitHub

Open Graph Title: @angular/build:unit-test hangs forever when two components in one file have identical inline styles · Issue #33317 · angular/angular-cli

X Title: @angular/build:unit-test hangs forever when two components in one file have identical inline styles · Issue #33317 · angular/angular-cli

Description: Command test 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.9 Description When two component definitions in the same source file declare byte-...

Open Graph Description: Command test 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.9 Description When two component definitio...

X Description: Command test 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.9 Description When two component definitio...

Opengraph URL: https://github.com/angular/angular-cli/issues/33317

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@angular/build:unit-test hangs forever when two components in one file have identical inline styles","articleBody":"### Command\n\ntest\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n21.2.9\n\n### Description\n\nWhen two component definitions in the same source file declare byte-identical inline `styles`, the `@angular/build:unit-test` builder (vitest browser runner, `watch:false`) runs all tests, prints the passing summary, and then never exits. In CI the job is killed at its timeout.\n\nThe hang is caused by a leaked esbuild build context. `process._getActiveHandles()` at the hang shows a single non-stdio handle: a `ChildProcess` for `…/@esbuild/…/esbuild --service=… --ping`. esbuild's service child is a singleton kept alive by any live build context, so one orphaned context keeps the Node event loop alive forever. Killing only that esbuild child makes the runner exit immediately with code 0.\n\n#### Root cause\n\nTwo compounding check-then-act races on the concurrent component-stylesheet bundling path:\n\n1. `Cache.getOrCreate` (`tools/esbuild/cache.ts`) is not concurrency-safe — it `await store.get()`, and only on `undefined` does it `await creator()` then `store.set()`. There is no in-flight promise memoization.\n\n2. Inline component styles are cached in a `MemoryCache` keyed on `[language, sha256(content), filename]` (`tools/esbuild/angular/component-stylesheets.ts` → `bundleInline`, `#inlineContexts`). Two components in the same file with identical CSS produce the same key.\n\n3. The compiler plugin bundles component stylesheets concurrently, so two `bundleInline` calls hit `getOrCreate` with that same key, both see an empty cache, and both run the creator — each constructing a `BundlerContext`.\n\n4. Even when they end up sharing one `BundlerContext`, the leak is sealed by a second race inside `BundlerContext.#performBundle()` (`tools/esbuild/bundler-context.ts`):\n\n   ```ts\n   if (this.#esbuildContext) {\n     result = await this.#esbuildContext.rebuild();\n   } else {\n     this.#esbuildContext = await context(this.#esbuildOptions); // await gap: both callers see undefined\n     result = await this.#esbuildContext.rebuild();\n   }\n   ```\n\n   Two concurrent `bundle()` calls both observe `#esbuildContext === undefined`, both call `context()`, and the second assignment overwrites the first. `dispose()` only disposes `#esbuildContext` (the second one); the first esbuild context is orphaned and never disposed, and `esbuild.stop()` is never called.\n\nInstrumenting a real run (hooking `BundlerContext.bundle`/`dispose`) shows 432 contexts created, 431 disposed — exactly one orphan, whose `bundleInline` arguments are a pair of components with identical inline CSS. Differentiating the CSS by one byte balances the counts and the process exits cleanly.\n\nSequential bundling does not leak (the second call reuses `#esbuildContext` via `rebuild()`); the leak strictly requires the concurrency that parallel stylesheet transforms reliably hit, so it is deterministic.\n\n### Minimal Reproduction\n\nRepo: \u003clink to a pushed copy of cc-12526-bug\u003e (a stock `@angular/build:unit-test` setup plus two specs). A zip is attached below.\n\n```bash\nnpm install\nnpx playwright install chromium\n\nnpm run test:hang   # two components, IDENTICAL inline styles -\u003e tests pass, then HANGS FOREVER\nnpm run test:ok     # same, one byte different               -\u003e tests pass, EXITS code 0\n```\n\nThe two scenarios live in separate source folders (`src/hang/`, `src/ok/`) with their own `tsConfig`/build configuration, because the unit-test builder bundles every spec matched by the build's tsConfig (not just those selected by the test `include`); a single shared build would let the duplicate-style spec poison the \"ok\" run too.\n\nThe only difference between hanging and passing is whether two inline `styles` strings are byte-identical:\n\n```ts\n// hang: ComponentA and ComponentB both use\nstyles: [`.box { width: 100px; height: 100px; }`]\n\n// ok: ComponentB differs by one byte\nstyles: [`.box { width: 100px; height: 100px; /* one byte different */ }`]\n```\n\nExpected: both commands exit with code 0 after the tests pass.\nActual: `test:hang` never exits; `test:ok` exits cleanly.\n\n### Exception or Error\n\n```text\n(no error — tests pass, vitest prints its summary, then the process hangs)\n\n Test Files  1 passed (1)\n      Tests  1 passed (1)\n\n# process._getActiveHandles() shows one lingering handle:\nChildProcess  .../@esbuild/\u003cplatform\u003e/esbuild(.exe) --service=\u003cver\u003e --ping\n```\n\n### Your Environment\n\n```text\n@angular/build: 22.0.0   (also reproduced on current main)\n@angular/cli:   22.0.0\nvitest:         4.1.0\n@vitest/browser-playwright: 4.1.0\nplaywright:     1.58.2\nNode.js:        22.22.3\nOS:             Windows 11 (also reproduces on Linux CI)\nRunner:         @angular/build:unit-test, vitest browser (Chromium), watch:false\n```\n\n### Anything else relevant?\n\n- Not a duplicate of #33201 (esbuild child after `ng build`): that path (`build-action`/`watch:false`) is fixed in 22.0.0 and disposes its context correctly; this leak is one level down in the stylesheet bundler's per-context creation.\n- Not a duplicate of #32832 (vitest `close()` vs `exit()`, fork-pool worker IPC handles): in browser mode there are no fork workers, and the only lingering handle here is the esbuild child, not a worker socket. `ctx.exit()`'s force-exit safety net would mask this hang, but the orphaned context would remain.\n- Suggested fix: memoize the in-flight `context()` promise in `BundlerContext.#performBundle()` (clearing it in `dispose()`) so concurrent `bundle()` calls share one esbuild context — the same \"create-once guard\" shape as f102f815e (Initiate PostCSS only once). Making `Cache.getOrCreate` store the pending creator promise would additionally harden the ~16 other call sites, but is not sufficient on its own for this bug.\n- A \"fix-it-in-userland\" workaround is to ensure no two components in one file share byte-identical inline `styles` (change a selector, value, or add a comment).\n\n[cc-12526-bug.zip](https://github.com/user-attachments/files/28647484/cc-12526-bug.zip)","author":{"url":"https://github.com/Klaster1","@type":"Person","name":"Klaster1"},"datePublished":"2026-06-05T16:52:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/33317/angular-cli/issues/33317"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a2b91c67-b882-c032-1065-96d7c6aaa47b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB258:32D223:45D0D7:66EAA3:6A6325CC
html-safe-nonce9fed1971a3643018cc81850bfa40db784edd2b089b5b3d86b744961adfd746af
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjU4OjMyRDIyMzo0NUQwRDc6NjZFQUEzOjZBNjMyNUNDIiwidmlzaXRvcl9pZCI6Ijg0Mjk2ODY1NDIxNzc2MDkxNjQiLCJyZWdpb25fZWRnZSI6Indlc3R1czIiLCJyZWdpb25fcmVuZGVyIjoid2VzdHVzMiJ9
visitor-hmac7cd49665cd3f2eed6aa79c7a29b7a057b3a03ba32680c57107614dd992f01f4b
hovercard-subject-tagissue:4598587969
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33317/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f39e2838fb6734648a49a5629c0757bd16b04b78c4bc1b0223e4526234727f8c/angular/angular-cli/issues/33317
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f39e2838fb6734648a49a5629c0757bd16b04b78c4bc1b0223e4526234727f8c/angular/angular-cli/issues/33317
og:image:altCommand test 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.9 Description When two component definitio...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKlaster1
hostnamegithub.com
expected-hostnamegithub.com
None1a6c056e02f174fffc096c521ec0ff6fb83e40a2ec8cb8875466ec1524872dd6
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6a93e25585f487ddff9e3996c06d5b869d6e1828
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/33317#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33317
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F33317
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/33317
Reloadhttps://github.com/angular/angular-cli/issues/33317
Reloadhttps://github.com/angular/angular-cli/issues/33317
Please reload this pagehttps://github.com/angular/angular-cli/issues/33317
angular https://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Notifications https://github.com/login?return_to=%2Fangular%2Fangular-cli
Fork 11.9k https://github.com/login?return_to=%2Fangular%2Fangular-cli
Star 27k https://github.com/login?return_to=%2Fangular%2Fangular-cli
Code https://github.com/angular/angular-cli
Issues 269 https://github.com/angular/angular-cli/issues
Pull requests 32 https://github.com/angular/angular-cli/pulls
Actions https://github.com/angular/angular-cli/actions
Security and quality 5 https://github.com/angular/angular-cli/security
Insights https://github.com/angular/angular-cli/pulse
Code https://github.com/angular/angular-cli
Issues https://github.com/angular/angular-cli/issues
Pull requests https://github.com/angular/angular-cli/pulls
Actions https://github.com/angular/angular-cli/actions
Security and quality https://github.com/angular/angular-cli/security
Insights https://github.com/angular/angular-cli/pulse
#33318https://github.com/angular/angular-cli/pull/33318
@angular/build:unit-test hangs forever when two components in one file have identical inline styleshttps://github.com/angular/angular-cli/issues/33317#top
#33318https://github.com/angular/angular-cli/pull/33318
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriagehttps://github.com/angular/angular-cli/milestone/11
https://github.com/Klaster1
Klaster1https://github.com/Klaster1
on Jun 5, 2026https://github.com/angular/angular-cli/issues/33317#issue-4598587969
@angular/build: leaves esbuild service child alive after watch:false build #33201https://github.com/angular/angular-cli/issues/33201
@angular/build:unit-test vitest executor hangs indefinitely — uses close() instead of exit() #32832https://github.com/angular/angular-cli/issues/32832
f102f81https://github.com/angular/angular-cli/commit/f102f815e404bcc2f627b7a52e92b3385eb9be5f
cc-12526-bug.ziphttps://github.com/user-attachments/files/28647484/cc-12526-bug.zip
area: @angular/buildhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular%2Fbuild%22
gemini-triagedLabel noting that an issue has been triaged by geminihttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
needsTriageNo due datehttps://github.com/angular/angular-cli/milestone/11
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.