Skip to content

fix(eio-client): close the probe transport when the probe fails - #5613

Open
mark1russell7 wants to merge 1 commit into
socketio:mainfrom
mark1russell7:fix/eio-client-failed-probe
Open

mark1russell7 wants to merge 1 commit into
socketio:mainfrom
mark1russell7:fix/eio-client-failed-probe

Conversation

@mark1russell7

Copy link
Copy Markdown

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

In _probe(), when the first packet received on the probe transport is not 3probe, the client emits upgradeError, but it does not call freezeTransport(), unlike the other failure paths (onerror, onTransportClose, onclose, onupgrade). The probe transport stays open, and its listeners stay on the socket: when the socket is closed later, upgradeError is emitted a second time.

New behavior

The branch calls freezeTransport() before it emits upgradeError: the probe transport is closed at once, its listeners are removed, and upgradeError is emitted once.

Other information (e.g. related issues)

Fixes #5612

The new test in test/node.js ("should close the probe transport when the probe fails") uses a small HTTP and WebSocket server that answers the probe with 3invalid. It expects the server to see the probe WebSocket closed while the socket is still open, and exactly one upgradeError event, also after socket.close().

Test results:

  • Node.js 24.21.0 on Windows 11, mocha 10.8.2, TypeScript 6.0.3, engine.io 6.6.11, xmlhttprequest-ssl 2.1.1 (the version of the lock file).
  • "Before" is the lib/ folder of main (545e984) with the tests of this branch.
  • The test hooks also build the browser bundle with rollup. This build was stubbed, because only the Node.js tests were run.
npx mocha --exit --require test/support/hooks.js --grep probe test/node.js
before after
default 0 passing, 1 failing (timeout of 2000 ms) 1 passing
USE_FETCH=1 0 passing, 1 failing (timeout of 2000 ms) 1 passing

Full Node.js suites of the branch: test/index.js 99 passing, 1 pending (USE_FETCH=1: 98 passing, 2 pending); main has 98 and 97 passing. test/webtransport.mjs: 10 passing, 1 failing (see below). prettier --check passes on the changed files.

The failure in test/webtransport.mjs also happens on main in this environment: "should send some binary data (server to client) (as ArrayBuffer)" (a timeout of 2000 ms). On main, "should allow to upgrade to WebTransport" also failed with a timeout in the same run.

This PR was prepared with AI assistance (Claude). The tests named above were run before and after the change, with the results above.

🤖 Generated with Claude Code

When the first packet received on the probe transport was not the
expected "3probe" pong, the "upgradeError" event was emitted but the
probe transport was not closed and its listeners were not removed. The
probe WebSocket stayed open until the socket itself was closed, and
"upgradeError" was then emitted a second time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[engine.io-client] a failed upgrade probe is not closed: the probe WebSocket stays open, and "upgradeError" is emitted twice

1 participant