Skip to content

Releases: socketio/engine.io-client

6.6.0

21 Jun 12:16
a17cbc5
Compare
Choose a tag to compare

Features

Custom transport implementations

The transports option now accepts an array of transport implementations:

import { Socket, XHR, WebSocket } from "engine.io-client";

const socket = new Socket({
  transports: [XHR, WebSocket]
});

Here is the list of provided implementations:

Transport Description
Fetch HTTP long-polling based on the built-in fetch() method.
NodeXHR HTTP long-polling based on the XMLHttpRequest object provided by the xmlhttprequest-ssl package.
XHR HTTP long-polling based on the built-in XMLHttpRequest object.
NodeWebSocket WebSocket transport based on the WebSocket object provided by the ws package.
WebSocket WebSocket transport based on the built-in WebSocket object.
WebTransport WebTransport transport based on the built-in WebTransport object.

Usage:

Transport browser Node.js Deno Bun
Fetch ✅ (1)
NodeXHR
XHR
NodeWebSocket
WebSocket ✅ (2)
WebTransport

(1) since v18.0.0
(2) since v21.0.0

Added in f4d898e and b11763b.

Transport tree-shaking

The feature above also comes with the ability to exclude the code related to unused transports (a.k.a. "tree-shaking"):

import { SocketWithoutUpgrade, WebSocket } from "engine.io-client";

const socket = new SocketWithoutUpgrade({
  transports: [WebSocket]
});

In that case, the code related to HTTP long-polling and WebTransport will be excluded from the final bundle.

Added in f4d898e

Test each low-level transports

When setting the tryAllTransports option to true, if the first transport (usually, HTTP long-polling) fails, then the other transports will be tested too:

import { Socket } from "engine.io-client";

const socket = new Socket({
  tryAllTransports: true
});

This feature is useful in two cases:

  • when HTTP long-polling is disabled on the server, or if CORS fails
  • when WebSocket is tested first (with transports: ["websocket", "polling"])

The only potential downside is that the connection attempt could take more time in case of failure, as there have been reports of WebSocket connection errors taking several seconds before being detected (that's one reason for using HTTP long-polling first). That's why the option defaults to false for now.

Added in 579b243.

Bug Fixes

  • add some randomness to the cache busting string generator (b624c50)
  • fix cookie management with WebSocket (Node.js only) (e105551)

Links

6.5.4

18 Jun 07:54
454940d
Compare
Choose a tag to compare

This release contains a bump of the ws dependency, which includes an important security fix.

Advisory: GHSA-3h5v-q93c-6h6q

Links

3.5.4

18 Jun 08:31
50ed08a
Compare
Choose a tag to compare

This release contains a bump of the ws dependency, which includes an important security fix.

Advisory: GHSA-3h5v-q93c-6h6q

Links

6.5.3

09 Nov 15:31
fa47916
Compare
Choose a tag to compare

Bug Fixes

  • add a maximum length for the URL (707597d)
  • improve compatibility with node16 module resolution (#711) (46ef851)

Credits

Huge thanks to @tylerbutler for helping!

Links

6.5.2

02 Aug 21:49
1097056
Compare
Choose a tag to compare

Bug Fixes

  • webtransport: add proper framing (d55c39e)
  • webtransport: honor the binaryType attribute (8270e00)

Credits

Huge thanks to @cdewbery for helping!

Links

6.5.1

28 Jun 06:50
500085d
Compare
Choose a tag to compare

Bug Fixes

  • make closeOnBeforeunload default to false (a63066b)
  • webtransport: properly handle abruptly closed connections (cf6aa1f)

Links

6.5.0

16 Jun 09:12
4abc2ca
Compare
Choose a tag to compare

Features

Support for WebTransport

The Engine.IO client can now use WebTransport as the underlying transport.

WebTransport is a web API that uses the HTTP/3 protocol as a bidirectional transport. It's intended for two-way communications between a web client and an HTTP/3 server.

References:

For Node.js clients: until WebTransport support lands in Node.js, you can use the @fails-components/webtransport package:

import { WebTransport } from "@fails-components/webtransport";

global.WebTransport = WebTransport;

Added in 7195c0f.

Cookie management for the Node.js client

When setting the withCredentials option to true, the Node.js client will now include the cookies in the HTTP requests, making it easier to use it with cookie-based sticky sessions.

import { Socket } from "engine.io-client";

const socket = new Socket("https://example.com", {
  withCredentials: true
});

Added in 5fc88a6.

Links

6.4.0

06 Feb 16:19
89487d8
Compare
Choose a tag to compare

The minor bump is due to changes on the server side.

Links

6.3.1

04 Feb 06:24
828d447
Compare
Choose a tag to compare

Bug Fixes

  • typings: do not expose browser-specific types (37d7a0a)

Links

  • Diff: 6.3.0...6.3.1
  • Server release: -
  • ws version: ~8.11.0 (no change)

6.3.0

10 Jan 16:10
e2b39b6
Compare
Choose a tag to compare

Bug Fixes

  • properly parse relative URL with a "@" character (12b7d78)
  • use explicit context for setTimeout function (#699) (047f420)

Features

The trailing slash which was added by default can now be disabled:

import { Socket } from "engine.io-client";

const socket = new Socket("https://example.com", {
  addTrailingSlash: false
});

In the example above, the request URL will be https://example.com/engine.io instead of https://example.com/engine.io/.

Links