partysocket: a URL provider that rejects with undefined gives an unhandled rejection and stops the reconnection
Chưa có ai nhận issue này.
Đá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
- 62/100
- Loại issue
- Lỗi
- Độ 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
Lỗi nằm ở .catch() của _connect() trong packages/partysocket/src/ws.ts (khoảng dòng 585-588), đoạn này đọc err.message từ một provider URL hoặc protocols bị reject. Chạy repro trong issue với partysocket 1.3.0 để xác nhận TypeError và trạng thái CONNECTING bị treo. Hoàn thành khi một provider reject với undefined hoặc null phát ra sự kiện error và lên lịch lần thử tiếp theo, không có unhandled rejection, và bộ test của partysocket chạy đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The .catch() of _connect() reads err.message. When the URL provider (or the protocols provider) rejects with undefined or null, for example with reject() and no argument, that line throws a TypeError inside the .catch(). The result is an unhandled rejection, no error event, and no next attempt: the socket stays in CONNECTING.
Repro
The packages: [email protected]. Install them with npm i [email protected].
// npm install, then: node repro.ts (Node.js 22.18 or later runs TypeScript directly)
import WebSocket from "partysocket/ws";
process.on("unhandledRejection", (reason) => {
console.log("unhandledRejection:", String(reason));
});
let calls = 0;
const ws = new WebSocket(
() => {
calls++;
// for example, reject() in a token fetcher
return Promise.reject(undefined);
},
undefined,
{ minReconnectionDelay: 50, maxReconnectionDelay: 50 },
);
let errors = 0;
ws.addEventListener("error", () => errors++);
setTimeout(() => {
console.log("provider calls in 500 ms:", calls);
console.log("error events:", errors);
console.log("readyState:", ws.readyState);
ws.close();
}, 500);
node repro.ts (Node.js 22.18 or later runs TypeScript directly)
Actual
unhandledRejection: TypeError: Cannot read properties of undefined (reading 'message')
provider calls in 500 ms: 1
error events: 0
readyState: 0
Expected
An error event, and a new attempt after the reconnection delay, as for a provider that rejects with an Error. No unhandled rejection.
A fix
A fix with a new test is on the branch fix/partysocket-provider-rejects-nullish of my fork, at 54a3d36. On a GitHub Actions runner, the new test fails before the change and passes after it, and the whole partysocket suite passes. This repository accepts pull requests only from collaborators, so I did not open a pull request. I can open one if you allow it, or you can take the commit.
I found this with AI assistance (Claude) during a review of WebSocket client libraries. The repro above was run with partysocket 1.3.0 on Node.js 24.22.2 on Linux (a GitHub Actions runner), and the output above is from that run. The fix was also prepared with AI assistance (Claude).
- Ngôn ngữ chính
- TypeScript
- Star
- 1.3k
- Fork
- 86
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudflare/partykit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
cloudflare/partykit#444 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
cloudflare/partykit#443 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cloudflare/partykit#430 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
cloudflare/partykit#429 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cloudflare/partykit#428 ·
Tất cả issue của cloudflare/partykit
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
steelbrain/node-ssh#487 ·
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundariesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
lingdojo/kana-dojo#34127 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
osmlab/name-suggestion-index#13104 ·
Maintainer thường phản hồi trong vòng 1 ngày