Angular SSR can crash `AngularAppEngine` servers with a single aborted request (22.2.6 regression)
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 20/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- angular, bun, deno, node.js, typescript
Rechercherichtung
Start by reviewing the linked change in packages/angular/ssr/src/utils/ng.ts and the reported bootstrap and error handling paths in Angular core. Reproduce the abort with the linked minimal reproduction, especially its pending initializer and firstValueFrom() cases. Done means an aborted render no longer crashes an AngularAppEngine server while preserving the render cancellation behavior.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
22.2.5
Description
Since @angular/ssr 22.2.6, a client that disconnects while a page is still rendering can kill the server process when it runs on AngularAppEngine: plain node:http, Hono, H3, srvx, Deno or Bun. The Express server from ng new --ssr is fine, because AngularNodeAppEngine installs process-wide error handlers.
#34568 made renderAngular() destroy the platform when request.signal aborts:
The host still gets the usual AbortError and handles it. What kills the process is the work that was still running. The clearest case is an app initializer: once it settles, bootstrap() reads the destroyed injector, and the internal error handler rethrows the NG0205 from a setTimeout because the injector is destroyed. Neither the app nor the host's try/catch can catch that, so it doesn't matter how the initializer is written:
Pending when the client disconnects, on AngularAppEngine |
Process |
|---|---|
provideAppInitializer from its usage notes |
exit 1 |
the same wrapped in try/catch |
exit 1 |
| an initializer that only waits on a 100 ms timer | exit 1 |
PendingTasks.run() as the zoneless guide shows it, awaiting an HttpClient call |
exit 1 |
firstValueFrom(http.get(...)) in async ngOnInit() (zoneless) |
exit 1 |
subscribe(), resolvers, guards, httpResource, resource() |
alive |
the try/catch initializer on 22.2.5, or on AngularNodeAppEngine |
alive |
The ngOnInit row is the other path: FetchBackend completes without a value once the app is destroyed, so firstValueFrom() rejects with EmptyError and nobody holds that promise. PendingTasks.run() passes that error to the same internal error handler, so it's rethrown from a setTimeout too.
It doesn't take precise timing. Every abort that arrived while the server was waiting on its backend killed it, 310 out of 310 with backends from 1 ms to 1 s, and nginx with its default config passes the abort on. The other pages that were rendering go down too. With Docker's restart: always, one aborted request every two seconds left the site serving 312 pages a minute instead of 5,584.
#34568 is right to stop the render, but the platform shouldn't be destroyed while that work is still pending, so the abort stays inside the promise handle() returns, the way it did on 22.2.5. AngularAppEngine is meant for platforms other than Node.js, so it can't count on process.on() handlers like AngularNodeAppEngine does.
Minimal Reproduction
https://github.com/SkyZeroZx/angular-ssr-abort-crash-lab
ng new --ssr with provideHttpClient(), RenderMode.Server on **, the SSR guide's non-Node entry on node:http, and a component that waits for its data during the render (api.mjs answers in 100 ms):
async ngOnInit() {
const { name } = await firstValueFrom(
this.http.get<{ name: string }>('http://127.0.0.1:4400/profile'),
);
this.profile.set(name);
}
npm ci && npx ng build
node api.mjs &
node dist/aborted-render-process/server/server.mjs &
sleep 2
curl -sS -o /dev/null -w "%{http_code}\n" http://localhost:4000/
curl -sS -m 0.05 http://localhost:4000/
sleep 1
curl -sS http://localhost:4000/
200
curl: (28) Operation timed out after 55 milliseconds with 0 bytes received
curl: (7) Failed to connect to localhost:4000 after 0 ms: Could not connect to server
The initializer version is in variants/initializer-trycatch, and cd docker && sh variants.sh initializer-trycatch builds and runs it. The README has the rest.
Exception or Error
The try/catch initializer, development build:
dist/aborted-render-process/server/main.server.mjs:4818
throw e;
^
RuntimeError: NG0205: Injector has already been destroyed. Find more at https://v22.angular.dev/errors/NG0205
at assertNotDestroyed (dist/aborted-render-process/server/main.server.mjs:3546:11)
at R3Injector.get (dist/aborted-render-process/server/main.server.mjs:3303:5)
at dist/aborted-render-process/server/main.server.mjs:26095:38
at async renderAngular (dist/aborted-render-process/server/main.server.mjs:43273:24)
The ngOnInit repro, development build:
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
Error
at new EmptyErrorImpl (dist/aborted-render-process/server/main.server.mjs:1783:3)
at Object.complete (dist/aborted-render-process/server/main.server.mjs:1802:18) {
message: 'no elements in sequence'
}
Your Environment
@angular/ssr 22.2.7
@angular/core 22.2.6, also 22.3.0
Node.js 24.16.0 on Windows 11, 24.22.3 in Docker
Also tried Hono 4.13, H3 2.0, srvx 1.0, Deno 2.9.8, Bun 1.4.4, nginx 1.30
Anything else relevant?
I think this is a vulnerability according to the SECURITY.md, which says:
DoS attacks which waste server resources significantly beyond the cost of the attacker's request may be security issues.
Here a single request crashes the server.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 27k
- Forks
- 11.8k
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 225
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus angular/angular-cli
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Offenarea: @angular/build
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
angular/angular-cli#34764 ·
Maintainer antworten meist innerhalb von 1 Tag
-
ng add @angular/ssr fails with TypeError when an NgModule in the app module file has no bootstrap arrayEvtl. vergeben @0z5a hat das heute übernommen. Offenarea: @schematics/angular
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
angular/angular-cli#34761 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
angular/angular-cli#34760 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: @schematics/angular
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 74/100
angular/angular-cli#34730 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: @angular/build
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
angular/angular-cli#34728 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in angular/angular-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
milind-soni/OpenMausBot#6730 ·
Maintainer antworten meist innerhalb von 1 Tag
-
status/need-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
google-gemini/gemini-cli#30384 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
P2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:image documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
docs enhancement examples good first issue
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag