Releases: socketio/engine.io-client
6.6.0
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
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
- Diff: 6.5.3...6.6.0
- Server release: 6.6.0
ws@~8.17.1
(no change)
6.5.4
This release contains a bump of the ws
dependency, which includes an important security fix.
Advisory: GHSA-3h5v-q93c-6h6q
Links
- Diff: 6.5.3...6.5.4
- Server release: -
ws@~8.17.1
(diff)
3.5.4
This release contains a bump of the ws
dependency, which includes an important security fix.
Advisory: GHSA-3h5v-q93c-6h6q
Links
- Diff: 3.5.3...3.5.4
- Server release: -
ws@~7.5.10
(diff)
6.5.3
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
- Diff: 6.5.2...6.5.3
- Server release: -
ws@~8.11.0
(no change)
6.5.2
Bug Fixes
Credits
Huge thanks to @cdewbery for helping!
Links
- Diff: 6.5.1...6.5.2
- Server release: -
ws@~8.11.0
(no change)
6.5.1
Bug Fixes
- make closeOnBeforeunload default to false (a63066b)
- webtransport: properly handle abruptly closed connections (cf6aa1f)
Links
- Diff: 6.5.0...6.5.1
- Server release: -
ws@~8.11.0
(no change)
6.5.0
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:
- https://w3c.github.io/webtransport/
- https://developer.mozilla.org/en-US/docs/Web/API/WebTransport
- https://developer.chrome.com/articles/webtransport/
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
- Diff: 6.4.0...6.5.0
- Server release: 6.5.0
- ws version:
~8.11.0
(no change)
6.4.0
The minor bump is due to changes on the server side.
Links
- Diff: 6.3.1...6.4.0
- Server release: 6.4.0
- ws version:
~8.11.0
(no change)
6.3.1
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
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
- Diff: 6.2.3...6.3.0
- Server release: 6.3.0
- ws version:
~8.11.0
(diff)