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

wasm: Close with codes other than 1000 throws, so CloseNow never closes

Đang mở
#575 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@0pcom đang làm issue này rồi.

Từ ngày 4/10/2026.

  • #576 của @0pcom — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
20/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
networking

Hướng nghiên cứu

The issue describes the failure in the js/wasm build when Conn.Close passes unsupported codes to the browser's WebSocket.close, and links PR #576, which is already open. Read that pull request and the Close/CloseNow path it changes; the issue's expected behavior is that rejected codes are sent as 1000 so the browser closes the socket without an error or panic.

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

Mô tả

In the js/wasm build, Conn.Close passes the code straight to the browser's WebSocket.close, which only accepts 1000 and 3000-4999 and throws InvalidAccessError for anything else. This package closes with 1001 (CloseNow), 1008 (read or dial context done), 1009 (read limit) and 1011 (write error), so all of those return an error and leave the socket open. Under TinyGo the throw is not recovered, so the program panics.

To reproduce, dial any server and call c.CloseNow(). In Chromium it returns:

failed to close WebSocket: JavaScript error: Failed to execute 'close' on 'WebSocket': The close code must be either 1000, or between 3000 and 4999. 1001 is neither.

A fix is to send 1000 to the browser for the codes it rejects. I have a PR for it.

Ngôn ngữ chính
Go
Star
5.5k
Fork
379
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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/websocket

Tất cả issue của coder/websocket

Issue tương tự

Thêm issue về Go

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.