socketio / socketio/socket.io

protocol(engine): Transport does not get updated when upgrade from WebSocket to WebTransport.

Open
#5,324 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

Describe the bug
Transport does not get updated when upgrade from WebSocket to WebTransport (when manually disable polling).

To Reproduce

Please fill the following code example:

Engine.IO server version: 6.6.4

Server

(Omitted, a correctly configured socket server with WebTransport enabled, see https://github.com/socketio/socket.io/blob/main/examples/webtransport/index.js)

Engine.IO client version: 6.6.3

Client

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Socket.IO WebTransport example</title>
  </head>
  <body>
    <script src="engine.io.js"></script>
    <script>
      const socket = new eio({
        transports: ['websocket', 'webtransport'],
        transportOptions: {
          websocket: { port: 1500 },
          webtransport: { port: 1650 },
        },
      });
    </script>
  </body>
</html>

Expected behavior
Subsequent request should sent by WebTransport.

Actual behavior
Image

engine.transport is still a WebSocket, marked upgrading = true, make it never success to sendmessage for both transports.

Additional context

In following code snippet, the callback in pause() would not be called if the original transport is WebSocket.

https://github.com/socketio/socket.io/blob/e95f6abf93766662cd3b341599ed312f4330213f/packages/engine.io-client/lib/socket.ts#L1029-L1042

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read packages/engine.io-client/lib/socket.ts around lines 1029-1042, starting with pause() and how the WebSocket-to-WebTransport upgrade is handled. Reproduce the configuration with transports set to websocket and webtransport, then verify that the transport is updated and subsequent requests use WebTransport without leaving the socket marked as upgrading.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.