Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#1,118 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
131
Fork
48
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của coder/vscode-coder

Tất cả issue của coder/vscode-coder

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.