Description
Create a new default Angular project
-
ng new
-
Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? (y/N) => Type y
-
In some component insert the below code: new WebSocket(
ws://localhost:3000/ws?userId=${something}
); -
TypeError [ERR_INVALID_ARG_TYPE]: The "event" argument must be an instance of Event. Received an instance of Event at WebSocket.dispatchEvent (node:internal/event_target:757:13) at fireEvent (node:internal/deps/undici/undici:11655:14) at #onConnectionEstablished (node:internal/deps/undici/undici:12824:9) at node:internal/deps/undici/undici:12632:66 at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at _ZoneDelegate.invokeTask (C:\...\apps\frontend\node_modules\zone.js\fesm2015\zone-node.js:402:33) at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at _ZoneDelegate.invokeTask (C:\\...\apps\frontend\node_modules\zone.js\fe at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at _ZoneDelegate.invokeTask (C:\\...\apps\frontend\node_modules\zone.js\fe at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at Object.processResponse (node:internal/deps/undici/undici:11998:11) at node:internal/deps/undici/undici:10727:23 at node:internal/deps/undici/undici:10727:23 at _ZoneDelegate.invokeTask (C:\\...\apps\frontend\node_modules\zone.js\fesm2015\zone-node.js:402:33) at ZoneImpl.runTask (C:\\...\apps\frontend\node_modules\zone.js\fesone-node.js:159:47) at drainMicroTaskQueue (C:\\...\apps\frontend\node_modules\zone.js\fesm2015\zone-node.js:581:35) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) { code: 'ERR_INVALID_ARG_TYPE'
Project Details :
System:
node -v: v22.14.0
npm -v 11.3.0
Frontend
"@angular/ssr": "~19.2.0",
"@angular/cdk": "^19.2.15",
"@angular/core": "~19.2.0",
Backend:
"@nestjs/platform-ws": "^11.1.0",
"@nestjs/websockets": "^11.1.0",
angular.json
` "server": "src/main.server.ts",
"prerender": true,
"ssr": {
"entry": "server.ts"
}`