Skip to content

Commit ee73dc9

Browse files
alan-agius4mmalerba
authored andcommitted
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
1 parent e6949ad commit ee73dc9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/platform-server/src/transfer_state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {BEFORE_APP_SERIALIZED} from './tokens';
2424
export const TRANSFER_STATE_SERIALIZED_FOR_APPID = new InjectionToken<Set<string>>(
2525
typeof ngDevMode === 'undefined' || ngDevMode ? 'TRANSFER_STATE_SERIALIZED_FOR_APPID' : '',
2626
{
27-
providedIn: 'platform',
27+
providedIn: 'root',
2828
factory: () => new Set(),
2929
},
3030
);
@@ -52,7 +52,7 @@ export function createScript(
5252
return script;
5353
}
5454

55-
export function warnIfStateTransferHappened(injector: Injector): void {
55+
function warnIfStateTransferHappened(injector: Injector): void {
5656
const appId = injector.get(APP_ID);
5757
const appIdsWithTransferStateSerialized = injector.get(TRANSFER_STATE_SERIALIZED_FOR_APPID);
5858

0 commit comments

Comments
 (0)