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

Open Beginner friendly
#4 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
javascript, node.js

Research direction

Open appserver.js and locate webSocketStartup; read the websocket.Server construction and the following startup calls. Remove the redundant listen call, then verify that startup no longer logs the not-a-function message and that WebSocket connections still work.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
7
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.