Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
area: @angular/buildgemini-triagedLabel noting that an issue has been triaged by geminineeds: repro stepsWe cannot reproduce the issue with the information given
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler-cli, compiler
Is this a regression?
Yes
Description
When building a completely clean, freshly generated Angular 22 project (ng new with SSR enabled), the production build (ng build) fails consistently with a "contents" must be a string or a Uint8Array error.
The project is completely pristine with no custom configurations or other third-party packages.
Key Observations:
- SSR Dependency: The error only occurs when Server-Side Rendering (SSR) is enabled during project generation. If I create the exact same clean project without SSR, the build succeeds.
- Dev Server Works: The development server (ng serve) works perfectly without any issues; it only crashes during ng build.
- Vite 8 / Rolldown Context: In earlier Angular 22 versions using Vite 7 (Rollup), this was not an issue. This freshly generated project uses the newer Vite 8 with the Rolldown bundler. It appears the angular-compiler plugin in esbuild fails to resolve or load these specific UI library modules during the SSR/prerendering build phase under this new architecture.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
This error came from the "onLoad" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:18:
397 │ build.onLoad({ filter: /\.[cm]?js$/ }, (0, load_resul...
╵ ~~~~~~
at setup (<workspace>/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:19)
at async handlePlugins (<workspace>/node_modules/esbuild/lib/main.js:1466:20)
The plugin "angular-compiler" was triggered by this import
src/app/shared/components/bs-reuse-tab/reuse-tab-context.service.ts:2:32:
2 │ import { ComponentPortal } from '@angular/cdk/portal';
╵ ~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
This error came from the "onLoad" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:18:
397 │ build.onLoad({ filter: /\.[cm]?js$/ }, (0, load_resul...
╵ ~~~~~~
at setup (<workspace>/node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:397:19)
at async handlePlugins (<workspace>/node_modules/esbuild/lib/main.js:1466:20)
The plugin "angular-compiler" was triggered by this import
src/app/shared/components/bs-reuse-tab/reuse-tab.component.ts:7:48:
7 │ import { NzTabComponent, NzTabsComponent } from 'ng-zorro-antd/tabs';
╵ ~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] "contents" must be a string or a Uint8Array [plugin angular-compiler]
node_modules/esbuild/lib/main.js:534:29:
534 │ if (mustBe !== null) throw new Error(`${quote(key)} must be ${m...
╵ ^
at getFlag (<workspace>/node_modules/esbuild/lib/main.js:534:30)
at requestCallbacks.on-load (<workspace>/node_modules/esbuild/lib/main.js:1559:26)
at async handleRequest (<workspace>/node_modules/esbuild/lib/main.js:909:11)
Please provide the environment you discovered this bug in (run ng version)
**Environment:**
Angular CLI : 22.1.3
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : linux x64 (KylinOS, Kernel: 5.4.18.63-generic x86_64)
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area: @angular/buildgemini-triagedLabel noting that an issue has been triaged by geminineeds: repro stepsWe cannot reproduce the issue with the information given
Activity
alan-agius4 commentedon Aug 13, 2026
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
imthiyazhassan commentedon Aug 13, 2026
I get the same error consistently on my Azure DevOps Linux agent, but works fine locally on my dev Windows machine. Issue started happening after I upgraded Angular from 21.2.19 to 22.1.4, and NodeJS from 22.13.1 to 24.19.0.
I do not have SSR enabled.
Bywdl commentedon Aug 14, 2026
I apologize, but I cannot provide a minimal reproduction repository because this is happening on a company-issued machine that does not allow external network access (an isolated environment).
However, I can provide the exact steps to reproduce it. Interestingly, you don't even need to install ng-zorro-antd or any third-party UI libraries to trigger this issue. A completely clean, out-of-the-box project created via ng new will throw this error.
Here are the reproduction steps:
Environment:
Angular CLI : 22.1.3
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : linux x64 (KylinOS, Kernel: 5.4.18.63-generic x86_64)
Create a New Project:
Run ng new to create a fresh project, and make sure to enable SSR during the prompt options.
Build the Project:
Navigate into the project directory and run npm run build (or ng build). Shortly after, the "contents" must be a string or a Uint8Array build error will occur.
I hope these steps help you locate and reproduce the issue on your end without needing a GitHub repository!
Bywdl commentedon Aug 14, 2026
Thanks for jumping in, @imthiyazhassan ! This is a massive clue.
Since it fails on your Azure DevOps Linux agent but works on Windows, and my environment is also Linux (KylinOS), we can safely rule out SSR and third-party libraries as the root cause.
It strongly points to a platform-specific issue with Linux + Node 24.x + Angular 22.1.x (esbuild/Vite 8 pipeline). It seems esbuild or the underlying file system reads return undefined/null instead of a Buffer/String under this specific combination.
To summarize for the Angular team, here is the failure matrix based on both of our reports:
Fails: Linux (KylinOS) + Node 24.16.0 + Angular 22.1.3 (My environment)
Fails: Linux (Azure DevOps) + Node 24.19.0 + Angular 22.1.4 (Your environment)
Works: Windows + Node 24.19.0 + Angular 22.1.4 (Your local dev environment)
@alan-agius4 - Could this be an issue with how esbuild/Vite 8 interacts with the Linux file system API in Node 24? This explains why it might be harder to reproduce on macOS/Windows dev machines.
@imthiyazhassan , since the Angular team usually requires standard environment details, could you run ng version on your Azure DevOps Linux agent and share the full output here?
This will automatically include your exact Linux distribution and architecture alongside your Node and Angular versions. Having that complete log will be super helpful to compare against my KylinOS environment and help the team pinpoint the issue!
imthiyazhassan commentedon Aug 14, 2026
Our build agents are on Ubuntu 20.04.6. Here is the output of ng version:
alan-agius4 commentedon Aug 14, 2026
Unfortunately, without a minimal reproduction, we aren't able to investigate this further. Most of our development and testing takes place on Linux, where we haven't been able to replicate the issue. If you can provide a minimal reproduction steps or code sample, we’d be happy to take another look.
Bywdl commentedon Aug 14, 2026
Here are the reproduction steps:
Environment:
Angular CLI : 22.1.3
Node.js : 24.16.0
Package Manager : npm 11.13.0
Operating System : linux x64 (KylinOS, Kernel: 5.4.18.63-generic x86_64)
Create a New Project:
Run ng new to create a fresh project, and make sure to enable SSR during the prompt options.
Build the Project:
Navigate into the project directory and run npm run build (or ng build). Shortly after, the "contents" must be a string or a Uint8Array build error will occur.
alan-agius4 commentedon Aug 14, 2026
@Bywdl/@imthiyazhassan please provide a runnable reproduction, without it we cannot look into this.
We are able to build successfully an
ng newapplication on Linux and Windows using Node.js 22.22.3, 24.15.0 and 26.0.0.You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.Bywdl commentedon Aug 14, 2026
I completely understand that a minimal reproduction repository is the standard procedure. However, as I mentioned, there is zero custom code to provide. The "minimal repro code" is literally just running ng new repro-app and then ng build. That is the entire codebase.
Since your team develops and tests on Linux without issues, I strongly suspect this is a system-level compatibility bug (likely related to glibc or the file system API) between Node 24.x, the new esbuild/Rolldown compiler, and specific Linux kernels.
Here are two crucial clues that might help your team replicate this:
Kernel Version Difference: Your testing environments likely use modern Linux kernels (e.g., 5.15+ or 6.x on Ubuntu 22.04/24.04). My KylinOS is running an older kernel (5.4.18.63).
Azure DevOps Environment: As another user mentioned in this thread, they are encountering the exact same contents must be a string or a Uint8Array error on an Azure DevOps Linux agent with Node 24.19.0.
Suggested Repro Steps for the Team:
Instead of a code repository, could you please try reproducing this by:
Spinning up a Docker container with an older Linux image (such as Ubuntu 20.04, which runs on a 5.4 kernel).
Or running a quick ng new -> ng build test via an Azure DevOps Linux pipeline with Node 24.16+ and Angular 22.1.3+.
This is definitely a real platform-specific bug affecting enterprise/CI Linux environments, not a user-code error. We would really appreciate it if you could take a second look from the environment perspective!
imthiyazhassan commentedon Aug 14, 2026
We upgraded our build agents to Ubuntu v24.04 and that resolved the issue.
manInit commentedon Aug 27, 2026
This is reproducible, but the trigger is not the kernel or the distro itself — it is the persistent cache store fallback, which is why it could not be reproduced here.
createPersistentCacheStore()tries LMDB first and silently falls back to the built-in SQLite store on any load failure. On Ubuntu 20.04 the prebuilt@lmdb/lmdb-linux-x64@3.5.6binary requiresGLIBC_2.33while the host provides glibc 2.31, so the fallback kicks in. Debian 11 and RHEL/CentOS 8 ship the same glibc. Upgrading the agent to Ubuntu 24.04 "fixes" it only because LMDB loads again there and the SQLite store is no longer used.The SQLite store persists values with
JSON.stringifyand reads them back withJSON.parse. Some cached values are binary —JavaScriptTransformeris constructed withCache<Uint8Array>, andCachedLoadResultEntry.contentsis typedstring | Uint8Array— and a JSON round trip cannot represent a typed array. A real row from.angular/cache/22.1.5/<project>/angular-compiler-sqlite.db:That plain object is then returned from the
onLoadcallback inangular/compiler-plugin.tsascontents, which produces the error. It only appears from the second build onwards, because the first build serves the value from the in-memory cache layer — the value is corrupted only once it has been read back from disk.Machine-independent reproduction, forcing the store through the existing environment option:
On a machine where LMDB loads normally, the broken store is never reached, so
ng new+ng buildwill not show it without that variable.Fix in #33947 — the store now serializes with the V8 structured clone API, which supports typed arrays natively and matches the LMDB store's behavior.
fix(@angular/build): preserve binary values in the SQLite cache store
fix(@angular/build): preserve binary values in the SQLite cache store
fix(@angular/build): preserve binary values in the SQLite cache store
angular-automatic-lock-bot commentedon Oct 20, 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.