angular/packages/core/src
Alan Agius 70d0639bc1
fix(core): introduce BootstrapContext for improved server bootstrapping (#63639)
* fix(core): introduce `BootstrapContext` for improved server bootstrapping

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);
```

A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call.

In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment.
2025-09-09 10:56:38 -07:00
..
application fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
authoring refactor: add explicit types for exports relying on inferred call return type (#61316) 2025-05-13 22:46:00 +00:00
change_detection docs: change the broked link (#60436) 2025-03-18 18:09:32 +01:00
compiler refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
debug refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
defer build: migrate platform-server to rules_js (#61619) 2025-05-22 15:34:07 -07:00
di build: migrate platform-browser and platform-browser-dynamic package to use rules_js (#61624) 2025-05-22 15:32:58 -07:00
hydration refactor(core): move i18n logic into its dedicated package (#61425) 2025-05-19 08:24:47 +00:00
i18n refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
interface refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
internal refactor(core): account for anonymous classes in internal utility (#58392) 2024-10-28 12:38:03 -07:00
linker docs: ViewContainerRef.createComponent jsdoc update (#61097) 2025-05-02 07:57:11 -07:00
metadata docs: replace EventEmitter with output and self-closing tags in templates (#60910) 2025-04-22 21:42:19 +02:00
platform fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
reflection refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
render docs: add link label & paragraph for correct display (#60708) 2025-04-30 08:18:08 -07:00
render3 fix(compiler): avoid conflicts between HMR code and local symbols (#61550) 2025-05-21 12:25:27 +00:00
resource refactor(core): convert scripts within packages/core/src to relative imports (#60227) (#60556) 2025-03-26 07:05:23 -07:00
sanitization refactor: add explicit types for exports relying on inferred call return type (#61316) 2025-05-13 22:46:00 +00:00
testability fix(core): cleanup testability subscriptions (#61261) 2025-05-21 12:06:24 +00:00
util build: migrate platform-server to rules_js (#61619) 2025-05-22 15:34:07 -07:00
view refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
zone refactor: update packages/core:{core,src} to ts_project (#61336) 2025-05-14 08:31:33 -07:00
authoring.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
cached_injector_service.ts refactor: add @__PURE__ next to @pureOrBreakMyCode for improved bundler compatibility (#58297) 2024-10-28 12:26:05 -07:00
change_detection.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
console.ts refactor: remove unnecessary TSLint rule flags (#59365) 2025-01-07 16:06:21 +00:00
core.externs.js refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
core.ts build: migrate platform-browser and platform-browser-dynamic package to use rules_js (#61624) 2025-05-22 15:32:58 -07:00
core_private_export.ts fix(core): introduce BootstrapContext for improved server bootstrapping (#63639) 2025-09-09 10:56:38 -07:00
core_reactivity_export.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
core_reactivity_export_internal.ts refactor(core): convert scripts within packages/core/src to relative imports (#60227) (#60556) 2025-03-26 07:05:23 -07:00
core_render3_private_export.ts fix(compiler): avoid conflicts between HMR code and local symbols (#61550) 2025-05-21 12:25:27 +00:00
di.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
error_details_base_url.ts docs: change xss doc url to angular new documentation (#59915) 2025-03-11 12:57:48 -07:00
error_handler.ts docs: set syntax highlighting of code examples MD code blocks (#59026) 2024-12-04 17:30:28 +01:00
errors.ts refactor(core): produce a message about @defer behavior when HMR is enabled (#60533) 2025-03-28 15:00:32 +00:00
event_delegation_utils.ts fix(core): enable stashing only when withEventReplay() is invoked (#61352) 2025-05-15 10:10:04 -07:00
event_emitter.ts fix(core): async EventEmitter error should not prevent stability (#61028) 2025-04-29 22:14:16 -07:00
image_performance_warning.ts refactor(core): drop platform check in ImagePerformanceWarning (#59809) 2025-02-20 12:32:23 -05:00
linker.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
metadata.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
pending_tasks.ts docs: set syntax highlighting to the remaining Markdown code examples blocks (#59088) 2025-01-14 15:14:02 -05:00
profiler.ts refactor(platform-server): Add an ssr benchmark setup. (#57647) 2024-10-04 10:45:22 -07:00
r3_symbols.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
render.ts feat(core): add event listener options to renderer (#59092) 2024-12-10 13:39:47 -08:00
transfer_state.ts refactor(core): replace PLATFORM_ID in initTransferState (#60299) 2025-03-10 13:49:24 -07:00
version.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
zone.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00