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

未关闭 适合新手
#4 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清

调研方向

打开 appserver.js 并找到 webSocketStartup;阅读 websocket.Server 的构造以及后续的 startup 调用。移除多余的 listen 调用,然后验证 startup 不再记录 not-a-function 消息,并且 WebSocket 连接仍然正常工作。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
JavaScript
星标
7
派生
3
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。