You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular's global patching in @angular/platform-server causes issues for other code expecting node's native event types #71977
Since Angular patches globalThis with domino.impl, node's Event and CustomEvent constructors are overwritten with non-intrinsic versions.
This causes issues for libraries like p-queue, which are implemented by extending EventTarget. When p-queue calls this.dispatchEvent(new CustomEvent()), node throws a TypeError
import'@angular/compiler';import{Component,provideZonelessChangeDetection}from'@angular/core';import{bootstrapApplication}from'@angular/platform-browser';import{renderApplication,provideServerRendering}from'@angular/platform-server';importPQueuefrom'p-queue';classApp{result='pending';constructor(){// p-queue 10 extends node's `EventTarget` and calls `this.dispatchEvent(new CustomEvent(...))`.// Once Angular's server platform has installed domino's globals, `CustomEvent` is domino's// implementation, which node's `EventTarget#dispatchEvent` rejects.constqueue=newPQueue({concurrency: 1});queue.add(()=>1);this.result='ok';}}Component({selector: 'app-root',template: `<p>{{ result }}</p>`})(App);consthtml=awaitrenderApplication((context)=>bootstrapApplication(App,{providers: [provideZonelessChangeDetection(),provideServerRendering()]},context,),{document: '<html><body><app-root></app-root></body></html>'},);console.log(html);
Please provide a link to a minimal reproduction of the bug
I'm unsure about this. I think it's quite unlikely to change that behavior, since Domino is tightly coupled to DOM emulation in Angular SSR as it works today.
A workaround like using isPlatformBrowser to execute that logic only in the browser is an alternative ( But it's not recommended anymore) , O better way is extracting that logic into a service using DI for the browser and server Providing platform-specific implementations would be a better approach
In my case, the code is intended to run on the server, not the browser. The repro is just a minimal example that will trigger it. Specifically, I hit this when Astro runs image optimization after rendering all the pages, but you could imagine an application server that uses p-queue for some task before or after calling renderApplication.
Activity
eblocha commentedon Nov 11, 2026
Tangential, but SSR may be a good case for shadow realms: https://github.com/tc39/proposal-shadowrealm
SkyZeroZx commentedon Nov 12, 2026
I'm unsure about this. I think it's quite unlikely to change that behavior, since Domino is tightly coupled to DOM emulation in Angular SSR as it works today.
A workaround like using
isPlatformBrowserto execute that logic only in the browser is an alternative ( But it's not recommended anymore) , O better way is extracting that logic into a service using DI for the browser and server Providing platform-specific implementations would be a better approacheblocha commentedon Nov 12, 2026
In my case, the code is intended to run on the server, not the browser. The repro is just a minimal example that will trigger it. Specifically, I hit this when Astro runs image optimization after rendering all the pages, but you could imagine an application server that uses p-queue for some task before or after calling
renderApplication.