mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(platform-server): prevent false warning for duplicate state serialization (#63525)
The `TRANSFER_STATE_SERIALIZED_FOR_APPID` provider was previously configured at the platform level, causing its state to be shared across all concurrent server-side rendering requests. This created a race condition where one request could see the `appId` from a different, concurrent request, leading to false warnings about duplicate state serialization. This commit changes the provider's scope to ensure that each application instance gets its own unique state. This correctly isolates the serialization check to each individual request, resolving the issue of false warnings in concurrent environments. Closes #63524 PR Close #63525
This commit is contained in:
committed by
Miles Malerba
parent
e6949ad355
commit
ee73dc9553
@@ -24,7 +24,7 @@ import {BEFORE_APP_SERIALIZED} from './tokens';
|
||||
export const TRANSFER_STATE_SERIALIZED_FOR_APPID = new InjectionToken<Set<string>>(
|
||||
typeof ngDevMode === 'undefined' || ngDevMode ? 'TRANSFER_STATE_SERIALIZED_FOR_APPID' : '',
|
||||
{
|
||||
providedIn: 'platform',
|
||||
providedIn: 'root',
|
||||
factory: () => new Set(),
|
||||
},
|
||||
);
|
||||
@@ -52,7 +52,7 @@ export function createScript(
|
||||
return script;
|
||||
}
|
||||
|
||||
export function warnIfStateTransferHappened(injector: Injector): void {
|
||||
function warnIfStateTransferHappened(injector: Injector): void {
|
||||
const appId = injector.get(APP_ID);
|
||||
const appIdsWithTransferStateSerialized = injector.get(TRANSFER_STATE_SERIALIZED_FOR_APPID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user