-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit 1cdca66
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 ddebe3d commit 1cdca66
File tree
14 files changed
+62
-36
lines changed- goldens/public-api/angular/ssr/node
- packages
- angular_devkit/build_angular/src/builders
- app-shell
- prerender
- angular
- build
- src/utils/server-rendering
- ssr
- node/src/common-engine
- src
- routes
- utils
- test
- schematics/angular/server/files
- application-builder/standalone-src
- server-builder/standalone-src
14 files changed
+62
-36
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 | + | ||
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
| |||
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
29 | - | ||
30 | + | ||
30 | 31 |
| |
31 | 32 |
| |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
36 | - | ||
37 | + | ||
37 | 38 |
| |
38 | 39 |
| |
39 | 40 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
127 | + | ||
127 | 128 |
| |
128 | 129 |
| |
129 | 130 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 | + | ||
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
15 | 16 |
| |
16 | 17 |
| |
17 | 18 |
| |
18 | - | ||
19 | + | ||
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
|
Lines changed: 6 additions & 3 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 |
| |
| |||
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
37 | - | ||
38 | + | ||
38 | 39 |
| |
39 | 40 |
| |
40 | 41 |
| |
| |||
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 | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 | + | ||
9 | 10 |
| |
10 | 11 |
| |
11 | 12 |
| |
|
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 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
93 | - | ||
94 | - | ||
95 | - | ||
96 | - | ||
97 | - | ||
98 | - | ||
99 | - | ||
100 | - | ||
101 | - | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | ||
105 | + | ||
102 | 106 |
| |
103 | 107 |
| |
104 | 108 |
|
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 |
| |
|
0 commit comments