[engine.io-client] close() called in an upgrade listener does not close the socket
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 20/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
- 領域
- backend, networking
調査の方向性
The issue points to packages/engine.io-client/lib/socket.ts and says a fix and test are already being submitted; linked pull request #5596 is open. Read that pull request and the upgrade handling around this.emitReserved("upgrade", transport) and this.upgrading = false to understand the change. The reported behavior is resolved when calling close() in an upgrade listener closes the socket immediately with reason forced close.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
Calling socket.close() in a listener of the upgrade event does not close the socket. The socket stays in the closing state and the WebSocket connection stays open. Since the client no longer answers the pings in that state, the server closes the connection once pingTimeout expires, so the close event comes pingInterval + pingTimeout later (45 seconds with the default values), with the reason transport close instead of forced close.
The upgrade event is emitted before upgrading is set back to false, so close() waits for the upgrade to finish, that is, for an upgrade event that has already been emitted.
To Reproduce
Engine.IO server version: 6.6.11
Engine.IO client version: 6.6.8 (also reproduced on main)
Server and client
const { createServer } = require("node:http");
const { attach } = require("engine.io");
const { Socket } = require("engine.io-client");
const httpServer = createServer();
const engine = attach(httpServer, { pingInterval: 2000, pingTimeout: 1000 });
httpServer.listen(3000, () => {
const socket = new Socket("http://localhost:3000");
let closedAt;
socket.on("upgrade", () => {
closedAt = Date.now();
socket.close();
console.log("readyState right after close():", socket.readyState);
});
socket.on("close", (reason) => {
console.log(`"close" event ${Date.now() - closedAt} ms after close(), reason: ${reason}`);
engine.close();
httpServer.close();
});
});
Output:
readyState right after close(): closing
"close" event 3059 ms after close(), reason: transport close
Expected behavior
The socket is closed right away, as when close() is called at any other time:
"close" event 2 ms after close(), reason: forced close
readyState right after close(): closed
Platform:
- Device: desktop
- OS: Windows, Node.js 24.22.1
Additional context
In packages/engine.io-client/lib/socket.ts, this.upgrading = false comes after this.emitReserved("upgrade", transport). I'm opening a PR with a fix and a test.
AI-assisted: found and reproduced with an AI coding agent; the example above was run locally.
- 主要言語
- TypeScript
- スター
- 63.2k
- フォーク
- 10.2k
- 平均マージ
- 6日 4時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
socketio/socket.io のほかの issue
-
[engine.io-client] The Node.js cookie jar lets Expires override Max-Age対応中かも @Ayush701-code-zm が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
socketio/socket.io#5590 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Raise Engine.IO minimum to 6.6.10 for published security fixes対応中かも @harshit-exe-dev が 29 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
Can't set response headers in Server.handleUpgrade対応中かも @MsfPablo が 90 日前に担当しました。 オープンquestion
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
socketio/socket.io#5497 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
WebTransport ignores query parameters in URL対応中かも @cyphercodes が 178 日前に担当しました。 オープンneeds major release question
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
socketio/socket.io#5496 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
[engine.io-client] Node.js: cookies pile up in extraHeaders and are resent on every reconnection対応中かも @adityajai119 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
メンテナーはふだん 2 日以内に返信
socketio/socket.io の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
g1331/phantom-circuit#93 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
compiler
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
HerringtonDarkholme/hd-lang#1699 ·
メンテナーはふだん 1 日以内に返信
-
account bug communication lecture
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信