Question
socketio-client causing "Internal server error: Page / did not render in 30 seconds" in Angular 18
I'm working on an Angular application where I use socketio-client within a SocketService. However, I encounter the following error when attempting to use the socket connection in the service constructor:
01:05:28 [vite] Internal server error: Page / did not render in 30 seconds.
at Timeout.<anonymous> (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\@angular\build\src\utils\server-rendering\render-page.js:90:90)
at Timeout.timer (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:2249:37)
at _ZoneDelegate.invokeTask (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:398:33)
at _ZoneImpl.runTask (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:158:47)
at invokeTask (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:479:34)
at Timeout.ZoneTask.invoke (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:468:48)
at Timeout.data.args.<computed> (C:\Users\azoul\OneDrive\Bureau\code\dm-front\node_modules\zone.js\fesm2015\zone-node.js:2231:32)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
socket.service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { io, Socket } from 'socket.io-client';
@Injectable({
providedIn: 'root'
})
export class SocketService {
private socket!: Socket;
constructor() {
this.socket = io('http://localhost:3000');
}
}
home.component.ts
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { SocketService } from '../../core/services/socket.service';
import { io, Socket } from 'socket.io-client';
@Component({
selector: 'app-home',
standalone: true,
imports: [
RouterLink // I use standalone components
],
templateUrl: './home.component.html',
styleUrl: './home.component.scss'
})
export class HomeComponent {
constructor(
private socketService: SocketService
) {}
}