Skip to content

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Sep 9, 2025

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

@alan-agius4 alan-agius4 added the target: lts This PR is targeting a version currently in long-term support label Sep 9, 2025
@alan-agius4 alan-agius4 force-pushed the 19-bootstrap-app branch 2 times, most recently from 224378e to 71bcbbe Compare September 9, 2025 08:10
@alan-agius4 alan-agius4 requested a review from jkrems September 9, 2025 08:36
…de 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);
```
In SSR applications, an unnecessary event loop tick during server startup could lead to an incorrect platform being initialized.

This change introduces an `ngJitMode` define, which is set to `false` during AOT builds. This allows for the JIT-specific code paths to not be followed, preventing the async operations that caused the extra tick. This ensures that the server platform is correctly and synchronously initialized.
In SSR applications, an unnecessary event loop tick during server startup could lead to an incorrect platform being initialized.

This change introduces an `ngJitMode` define, which is set to `false` during AOT builds. This allows for the JIT-specific code paths to not be followed, preventing the async operations that caused the extra tick. This ensures that the server platform is correctly and synchronously initialized.
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed state: blocked labels Sep 10, 2025
@alan-agius4 alan-agius4 force-pushed the 19-bootstrap-app branch 3 times, most recently from b02ac1e to febdcd0 Compare September 10, 2025 18:37
Update FW packages to latest patch version
@alan-agius4 alan-agius4 added the detected: breaking change PR contains a commit with a breaking change label Sep 10, 2025
@alan-agius4 alan-agius4 merged commit c4278aa into angular:19.2.x Sep 10, 2025
27 of 31 checks passed
@alan-agius4 alan-agius4 deleted the 19-bootstrap-app branch September 10, 2025 19:21
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker 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.

2 participants