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

Aperta Adatta ai principianti
#4 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
javascript, node.js

Direzione di ricerca

Apri appserver.js e individua webSocketStartup; leggi la costruzione di websocket.Server e le chiamate di avvio successive. Rimuovi la chiamata ridondante a listen, quindi verifica che l'avvio non registri più il messaggio not-a-function e che le connessioni WebSocket continuino a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
7
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.