Skip to content

Conversation

alan-agius4
Copy link
Contributor

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:

const bootstrap = () => bootstrapApplication(AppComponent, config);

After:

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.

(cherry picked from commit 8bf80c9)

@alan-agius4 alan-agius4 added the target: lts This PR is targeting a version currently in long-term support label Sep 8, 2025
@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change area: core Issues related to the framework runtime labels Sep 8, 2025
@ngbot ngbot bot added this to the Backlog milestone Sep 8, 2025
@angular-robot angular-robot bot added area: build & ci Related the build and CI infrastructure of the project area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 8, 2025
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from 7d57459 to b9aeba2 Compare September 8, 2025 13:31
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 8, 2025
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 8, 2025
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from d68caf2 to 4bc5fba Compare September 8, 2025 14:27
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 8, 2025
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 9, 2025
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from 6e61a1a to 928aa8f Compare September 9, 2025 06:48
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 9, 2025
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from bab9312 to fb203df Compare September 9, 2025 07:14
@angular-robot angular-robot bot removed the area: core Issues related to the framework runtime label Sep 9, 2025
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Sep 9, 2025
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from c89fefa to b708d1b Compare September 9, 2025 08:25
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 9, 2025
Use a more recent SHA, to fix issues with Chrome sandboxing.
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from b708d1b to 92f791c Compare September 9, 2025 09:07
@angular-robot angular-robot bot removed the area: core Issues related to the framework runtime label Sep 9, 2025
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 9, 2025
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Sep 9, 2025
@alan-agius4 alan-agius4 marked this pull request as ready for review September 9, 2025 09:07
The `ng_update_migrations` integration test is consistently failing due to Node.js engine incompatibilities. The test attempts to install an old version of  `@angular/cli` (v12) which requires a Node.js version that is no longer available in our CI environment.

This test has already been removed in the v19 branch. To align with that precedent and remove a failing test that is difficult to maintain, this commit removes the test entirely.
This commit separates the integration tests into their own CI job.
This change aims to speed up the overall CI process by allowing
integration tests to run independently. This also aligns the CI
configuration with the v19 branch.
@alan-agius4 alan-agius4 force-pushed the 18.2-platform-injector branch from 92f791c to 91b1d83 Compare September 9, 2025 09:16
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 9, 2025
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: dev-infra

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: global-approvers

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 9, 2025
@alan-agius4 alan-agius4 removed the request for review from devversion September 9, 2025 17:04
atscott pushed a commit that referenced this pull request Sep 9, 2025
…ping (#63640)

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.

(cherry picked from commit 8bf80c9)

PR Close #63640
atscott pushed a commit that referenced this pull request Sep 9, 2025
This commit updates all usages of `angular/dev-infra/github-actions` to their latest SHA.
This is necessary to ensure that all workflows are using the most up-to-date versions of the actions,
which can include bug fixes, performance improvements, or new features.

PR Close #63640
atscott pushed a commit that referenced this pull request Sep 9, 2025
Use a more recent SHA, to fix issues with Chrome sandboxing.

PR Close #63640
atscott pushed a commit that referenced this pull request Sep 9, 2025
The `ng_update_migrations` integration test is consistently failing due to Node.js engine incompatibilities. The test attempts to install an old version of  `@angular/cli` (v12) which requires a Node.js version that is no longer available in our CI environment.

This test has already been removed in the v19 branch. To align with that precedent and remove a failing test that is difficult to maintain, this commit removes the test entirely.

PR Close #63640
@atscott
Copy link
Contributor

atscott commented Sep 9, 2025

This PR was merged into the repository. The changes were merged into the following branches:

atscott pushed a commit that referenced this pull request Sep 9, 2025
This commit separates the integration tests into their own CI job.
This change aims to speed up the overall CI process by allowing
integration tests to run independently. This also aligns the CI
configuration with the v19 branch.

PR Close #63640
@atscott atscott closed this Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project area: core Issues related to the framework runtime detected: breaking change PR contains a commit with a breaking change target: lts This PR is targeting a version currently in long-term support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants