webSocketStartup logs "theWsServer.listen is not a function" — redundant .listen() call after constructor already starts the server

Abierto Apto para principiantes
#4 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
85/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
javascript, node.js

Línea de trabajo

Abre appserver.js y localiza webSocketStartup; lee la construcción de websocket.Server y las llamadas de startup que aparecen a continuación. Elimina la llamada redundante a listen y verifica después que el startup ya no registre el mensaje not-a-function y que las conexiones WebSocket sigan funcionando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

When installing a test instance of rss.chat, Claude Code flagged an websockets error that turned out to not be an error. Here is Claude's bug report.


In appserver.js v0.8.3, the webSocketStartup function (rewritten 5/25/25) calls theWsServer.listen() after constructing the server with a port option:

theWsServer = new websocket.Server({port: config.websocketPort}); //5/25/25 by DW
theWsServer.on ("connection", handleWebSocketConnection);         //5/25/25 by DW
console.log ("webSocketStartup: config.websocketPort == " + config.websocketPort);
theWsServer.listen (config.websocketPort);   // ← throws

ws.Server has never exposed a public .listen() method. When you pass port to the constructor, the library creates an internal net.Server and calls .listen() on it automatically — the socket is already bound and ready before that last line runs. The call throws, the catch logs "webSocketStartup: err.message == theWsServer.listen is not a function", and the function returns.

The server is not broken — port binding and the connection handler are both set up before the throw, so WebSocket connections work normally. But the logged message looks like a fatal startup failure and will alarm anyone reading the logs.

Fix: remove the redundant .listen() call.

function webSocketStartup () {
    if (config.flWebsocketEnabled) {
        try {
            theWsServer = new websocket.Server({port: config.websocketPort});
            theWsServer.on ("connection", handleWebSocketConnection);
            console.log ("webSocketStartup: listening on port " + config.websocketPort);
            }
        catch (err) {
            console.log ("webSocketStartup: err.message == " + err.message);
            }

Environment: daveappserver 0.8.3, ws 8.21.1, Node v24.18.0.

Lenguaje dominante
JavaScript
Estrellas
7
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.