-
Notifications
You must be signed in to change notification settings - Fork 26.6k
feat(platform-server): update server bootstrap API #63562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
93d4db6
to
a2d0427
Compare
b705644
to
6947b29
Compare
caretaker note: this requires a separate patch in G3 http://cl/802466606 |
6947b29
to
837b218
Compare
* Having a separate symbol for the module boostrap implementation allows us to | ||
* tree shake the module based boostrap implementation in standalone apps. | ||
* Having a separate symbol for the module bootstrap implementation allows us to | ||
* tree shake the module based bootstrap implementation in standalone apps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much less scary without all the "boos"!
(Thanks for cleaning these up!)
packages/core/schematics/migrations/bootstrap-application-to-server-application/README.md
Outdated
Show resolved
Hide resolved
f93674e
to
3615fd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: dev-infra
@@ -45,7 +50,7 @@ export class PlatformState { | |||
export function provideServerRendering(): EnvironmentProviders; | |||
|
|||
// @public | |||
export function renderApplication<T>(bootstrap: () => Promise<ApplicationRef>, options: { | |||
export function renderApplication(bootstrap: ReturnType<typeof bootstrapServerApplication>, options: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious how would this be rendered on ADEV. As an option, we can introduce a new type here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does render correctly. See: https://ng-dev-previews-fw--pr-angular-angular-63562-adev-prev-fbt65dr2.web.app/api/platform-server/renderApplication
const bootstrap = bootstrapServerApplication(AppComponent, config); | ||
|
||
export default bootstrap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the generated code, can we just do this or it's better to have a const?
export default bootstrapServerApplication(AppComponent, config);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can, although I did not change it in the existing code.
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. To address this, the bootstrapping process now explicitly passes the `platformInjector` through the `bootstrapServerApplication` and `renderApplication` functions. This ensures that each server-side render has its own isolated platform injector, preventing state leakage between requests. The `bootstrapApplication` function will now throw an error when used on the server. Instead, developers should use the newly introduced `bootstrapServerApplication` function from `@angular/platform-server`. In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment. BREAKING CHANGE: - `bootstrapApplication` can no longer be used on the server. Instead, `bootstrapServerApplication` from `@angular/platform-server` should be used. - `renderApplication` now requires the return value of `bootstrapServerApplication`. - `getPlatform()` and `destroyPlatform()` are now no-ops on the server and `getPlatform()` will return `null`.
9dce5cf
to
8dab173
Compare
Deployed adev-preview for 697d3a8 to: https://ng-dev-previews-fw--pr-angular-angular-63562-adev-prev-fbt65dr2.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
669792e
to
697d3a8
Compare
697d3a8
to
4ce8bc6
Compare
4ce8bc6
to
ff571e6
Compare
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.
To address this, the bootstrapping process now explicitly passes the
platformInjector
through thebootstrapServerApplication
andrenderApplication
functions. This ensures that each server-side render has its own isolated platform injector, preventing state leakage between requests.The
bootstrapApplication
function will now throw an error when used on the server. Instead, developers should use the newly introducedbootstrapServerApplication
function from@angular/platform-server
.In addition,
getPlatform()
anddestroyPlatform()
will now returnnull
and be a no-op respectively when running in a server environment.BREAKING CHANGE:
bootstrapApplication
can no longer be used on the server. Instead,bootstrapServerApplication
from@angular/platform-server
should be used.renderApplication
now requires the return value ofbootstrapServerApplication
.getPlatform()
anddestroyPlatform()
are now no-ops on the server andgetPlatform()
will returnnull
.