-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Which @ngrx/* package(s) are the source of the bug?
component
Minimal reproduction of the bug/regression with instructions
When using ngrxLet in a angular app with both SSR and zoneless, you're faced with an error:
uncaughtException ReferenceError: requestAnimationFrame is not defined.
I made a quick example:
https://github.com/JelleBruisten/ngrxlet-zoneless-ssr
It looks like due that when zoneless we use the AnimationFrameTickScheduler
@Injectable({
providedIn: 'root',
useFactory: () => {
const zone = inject(NgZone);
return isNgZone(zone)
? new NoopTickScheduler()
: inject(AnimationFrameTickScheduler);
},
})
export abstract class TickScheduler {
abstract schedule(): void;
}
And within AnimationFrameTickScheduler we use this, but requestAnimationFrame does not exist in node during the server render:
schedule(): void {
if (!this.isScheduled) {
this.isScheduled = true;
requestAnimationFrame(() => {
this.appRef.tick();
this.isScheduled = false;
});
}
}
We're throwing an error
Expected behavior
To schedule using a different mechanism maybe setTimeout while on server?
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
ngrx: 19.2.1 ( did try it with latest 20.0.0-rc... )
angular: v20
Other information
No response
I would be willing to submit a PR to fix this issue
- Yes
- No