animationFrameScheduler throws in SSR mode

Bug Report

Current Behavior
My Angular app is using a 3rd party library: ngx-highlightjs and it throws an error when running the app in SSR mode:

requestAnimationFrame is not defined

Digging into the stack trace revealed it’s due to the use of this line:

animationFrameScheduler.schedule(() =>
  // ...
);

Reproduction

  • Repo link: I will update this shortly

Expected behavior
I’m actually not sure if it should be the responsibility of rxjs to make animationFrameScheduler work in NodeJS or if it should be the responsibility of the library author to write SSR-friendly implementation.

It looks like there are a lot of similar issues in the wild so my first impression is for this issue to be fixed at the rxjs level. Then all these other issues will miraculously be resolved!

Environment

  • Runtime: Node v12
  • RxJS version: 6.6.3
  • angular/core: 9.1.13 (in case this is relevant)

1 possible answer(s) on “animationFrameScheduler throws in SSR mode

  1. Same as ajaxObservable which requires proper polyfill to XHR on node.js which doesn’t support it out of the box, I believe this should be polyfilled by each application if it’s needed to be used on runtime does not have suport for it.