Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Read handshake status from public API instead of parsing library error strings

已关闭
#1,118 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
networking

调研方向

Read handshakeStatus in src/websocket/utils.ts and trace the SSE path through SseConnection.createErrorEvent in src/websocket/sseConnection.ts; first run test/unit/websocket/utils.test.ts to understand the existing coverage. Check how the public event data reaches handshakeStatus, then verify that unrecoverable-HTTP handling and the SSE 404 fallback still work without relying on error message text.

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

描述

enhancement tech-debt
Background

handshakeStatus (src/websocket/utils.ts) recovers the HTTP status of a failed
WebSocket/SSE handshake by parsing the error message text from two libraries:

  • ws — Unexpected server response: <code>
  • eventsource — Non-200 status code (<code>)

Neither string is a public contract; both are plain template literals
(ws/lib/websocket.js and eventsource/src/EventSource.ts). If either reword on
a version bump, handshakeStatus returns undefined, every unrecoverable status
becomes a retry-forever connection_error, and CoderApi.is404Error stops
falling back to SSE.

A real-library test (test/unit/websocket/utils.test.ts) now guards against a
silent reword by failing in CI, but parsing internal strings is still fragile.

Proposal

Read the status from the libraries' public event APIs instead of the message:

  • SSE: eventsource puts the status on ErrorEvent.code (documented public
    API). SseConnection.createErrorEvent (src/websocket/sseConnection.ts)
    currently reads only message and error and drops code; surface it.
  • WebSocket: ws exposes the same on its unexpected-response event, which
    also suppresses the string path once handled.

Once the status comes from the events, handshakeStatus's string parsing can be
narrowed or removed.

Acceptance
  • Handshake status is derived from ErrorEvent.code / the ws
    unexpected-response event, not the error message text.
  • Unrecoverable-HTTP handling and the SSE 404 fallback keep working.

Filed by Coder Agents on behalf of @aqandrew, as a follow-up to PR #1100.

主要语言
TypeScript
星标
132
派生
48
平均合并
2 天 5 小时
30 天内合并 PR
19

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

coder/vscode-coder 的其他 Issue

查看 coder/vscode-coder 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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