-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit 66cf119
committed
feat(@angular/ssr): introduce BootstrapContext for isolated server-side rendering
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests.
Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state.
The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable.
BREAKING CHANGE:
The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector.
Before:
```ts
const bootstrap = () => bootstrapApplication(AppComponent, config);
```
After:
```ts
const bootstrap = (context: BootstrapContext) =>
bootstrapApplication(AppComponent, config, context);
```1 parent e6a3b55 commit 66cf119
File tree
8 files changed
+39
-22
lines changed- packages
- angular_devkit/build_angular/src/builders
- app-shell
- prerender
- angular/ssr
- node/src/common-engine
- src
- routes
- utils
- schematics/angular/server/files
- application-builder/standalone-src
- server-builder/standalone-src
8 files changed
+39
-22
lines changedLines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 | + | ||
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
26 | - | ||
27 | + | ||
27 | 28 |
| |
28 | 29 |
| |
29 | 30 |
| |
| |||
197 | 198 |
| |
198 | 199 |
| |
199 | 200 |
| |
200 | - | ||
201 | + | ||
202 | + | ||
203 | + | ||
201 | 204 |
| |
202 | 205 |
| |
203 | 206 |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
634 | 634 |
| |
635 | 635 |
| |
636 | 636 |
| |
637 | - | ||
637 | + | ||
638 | 638 |
| |
639 | 639 |
| |
640 | 640 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
356 | 356 |
| |
357 | 357 |
| |
358 | 358 |
| |
359 | - | ||
359 | + | ||
360 | 360 |
| |
361 | 361 |
| |
362 | 362 |
| |
363 | 363 |
| |
364 | 364 |
| |
365 | - | ||
366 | - | ||
367 | - | ||
368 | - | ||
369 | - | ||
370 | - | ||
371 | - | ||
372 | - | ||
365 | + | ||
366 | + | ||
367 | + | ||
368 | + | ||
369 | + | ||
370 | + | ||
371 | + | ||
372 | + | ||
373 | + | ||
374 | + | ||
375 | + | ||
373 | 376 |
| |
374 | 377 |
| |
375 | 378 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 | + | ||
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
| |||
31 | 32 |
| |
32 | 33 |
| |
33 | 34 |
| |
34 | - | ||
35 | + | ||
36 | + | ||
37 | + | ||
35 | 38 |
| |
36 | 39 |
| |
37 | 40 |
| |
| |||
90 | 93 |
| |
91 | 94 |
| |
92 | 95 |
| |
93 | - | ||
96 | + | ||
94 | 97 |
| |
95 | 98 |
| |
96 | 99 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 | + | ||
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
36 | - | ||
37 | + | ||
37 | 38 |
| |
38 | 39 |
| |
39 | 40 |
| |
| |||
121 | 122 |
| |
122 | 123 |
| |
123 | 124 |
| |
124 | - | ||
125 | + | ||
126 | + | ||
127 | + | ||
125 | 128 |
| |
126 | 129 |
| |
127 | 130 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 | + | ||
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
42 | 43 |
| |
43 | 44 |
| |
44 | 45 |
| |
45 | - | ||
46 | + | ||
46 | 47 |
| |
47 | 48 |
| |
48 | 49 |
| |
| |||
148 | 149 |
| |
149 | 150 |
| |
150 | 151 |
| |
151 | - | ||
152 | + | ||
153 | + | ||
154 | + | ||
152 | 155 |
| |
153 | 156 |
| |
154 | 157 |
| |
|
packages/schematics/angular/server/files/application-builder/standalone-src/main.server.ts.template
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | - | ||
1 | + | ||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 | - | ||
5 | + | ||
6 | + | ||
6 | 7 |
| |
7 | 8 |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | - | ||
1 | + | ||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 | - | ||
5 | + | ||
6 | + | ||
6 | 7 |
| |
7 | 8 |
|
0 commit comments