socketio/socket.io (socket.io)
### [`v4.7.5`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#475-2024-03-14)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.4...4.7.5)
##### Bug Fixes
- close the adapters when the server is closed ([bf64870](https://togithub.com/socketio/socket.io/commit/bf64870957e626a73e0544716a1a41a4ba5093bb))
- remove duplicate pipeline when serving bundle ([e426f3e](https://togithub.com/socketio/socket.io/commit/e426f3e8e1bfea5720c32d30a3663303200ee6ad))
##### Dependencies
- [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.4`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#474-2024-01-12)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.3...4.7.4)
##### Bug Fixes
- **typings:** calling io.emit with no arguments incorrectly errored ([cb6d2e0](https://togithub.com/socketio/socket.io/commit/cb6d2e02aa7ec03c2de1817d35cffa1128b107ef)), closes [#4914](https://togithub.com/socketio/socket.io/issues/4914)
##### Dependencies
- [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.3`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#473-2024-01-03)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.2...4.7.3)
##### Bug Fixes
- return the first response when broadcasting to a single socket ([#4878](https://togithub.com/socketio/socket.io/issues/4878)) ([df8e70f](https://togithub.com/socketio/socket.io/commit/df8e70f79822e3887b4f21ca718af8a53bbda2c4))
- **typings:** allow to bind to a non-secure Http2Server ([#4853](https://togithub.com/socketio/socket.io/issues/4853)) ([8c9ebc3](https://togithub.com/socketio/socket.io/commit/8c9ebc30e5452ff9381af5d79f547394fa55633c))
##### Dependencies
- [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#472-2023-08-02)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.1...4.7.2)
##### Bug Fixes
- clean up child namespace when client is rejected in middleware ([#4773](https://togithub.com/socketio/socket.io/issues/4773)) ([0731c0d](https://togithub.com/socketio/socket.io/commit/0731c0d2f497d5cce596ea1ec32a67c08bcccbcd))
- **webtransport:** properly handle WebTransport-only connections ([3468a19](https://togithub.com/socketio/socket.io/commit/3468a197afe87e65eb0d779fabd347fe683013ab))
- **webtransport:** add proper framing ([a306db0](https://togithub.com/socketio/engine.io/commit/a306db09e8ddb367c7d62f45fec920f979580b7c))
##### Dependencies
- [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) ([diff](https://togithub.com/socketio/engine.io/compare/6.5.0...6.5.2))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.1`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#471-2023-06-28)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.0...4.7.1)
The client bundle contains a few fixes regarding the WebTransport support.
##### Dependencies
- [`engine.io@~6.5.0`](https://togithub.com/socketio/engine.io/releases/tag/6.5.0) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.0`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#470-2023-06-22)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.2...4.7.0)
##### Bug Fixes
- remove the Partial modifier from the socket.data type ([#4740](https://togithub.com/socketio/socket.io/issues/4740)) ([e5c62ca](https://togithub.com/socketio/socket.io/commit/e5c62cad60fc7d16fbb024fd9be1d1880f4e6f5f))
##### Features
##### Support for WebTransport
The Socket.IO server 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/
Until WebTransport support lands [in Node.js](https://togithub.com/nodejs/node/issues/38478), you can use the `@fails-components/webtransport` package:
```js
import { readFileSync } from "fs";
import { createServer } from "https";
import { Server } from "socket.io";
import { Http3Server } from "@fails-components/webtransport";
// WARNING: the total length of the validity period MUST NOT exceed two weeks (https://w3c.github.io/webtransport/#custom-certificate-requirements)
const cert = readFileSync("/path/to/my/cert.pem");
const key = readFileSync("/path/to/my/key.pem");
const httpsServer = createServer({
key,
cert
});
httpsServer.listen(3000);
const io = new Server(httpsServer, {
transports: ["polling", "websocket", "webtransport"] // WebTransport is not enabled by default
});
const h3Server = new Http3Server({
port: 3000,
host: "0.0.0.0",
secret: "changeit",
cert,
privKey: key,
});
(async () => {
const stream = await h3Server.sessionStream("/socket.io/");
const sessionReader = stream.getReader();
while (true) {
const { done, value } = await sessionReader.read();
if (done) {
break;
}
io.engine.onWebTransportSession(value);
}
})();
h3Server.startServer();
```
Added in [123b68c](https://togithub.com/socketio/engine.io/commit/123b68c04f9e971f59b526e0f967a488ee6b0116).
##### Client bundles with CORS headers
The bundles will now have the right `Access-Control-Allow-xxx` headers.
Added in [63f181c](https://togithub.com/socketio/socket.io/commit/63f181cc12cbbbf94ed40eef52d60f36a1214fbe).
##### Dependencies
- [`engine.io@~6.5.0`](https://togithub.com/socketio/engine.io/releases/tag/6.5.0) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.2...6.5.0))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#462-2023-05-31)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.1...4.6.2)
##### Bug Fixes
- **exports:** move `types` condition to the top ([#4698](https://togithub.com/socketio/socket.io/issues/4698)) ([3d44aae](https://togithub.com/socketio/socket.io/commit/3d44aae381af38349fdb808d510d9f47a0c2507e))
##### Dependencies
- [`engine.io@~6.4.2`](https://togithub.com/socketio/engine.io/releases/tag/6.4.0) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.1...6.4.2))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.1`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#461-2023-02-20)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.0...4.6.1)
##### Bug Fixes
- properly handle manually created dynamic namespaces ([0d0a7a2](https://togithub.com/socketio/socket.io/commit/0d0a7a22b5ff95f864216c529114b7dd41738d1e))
- **types:** fix nodenext module resolution compatibility ([#4625](https://togithub.com/socketio/socket.io/issues/4625)) ([d0b22c6](https://togithub.com/socketio/socket.io/commit/d0b22c630208669aceb7ae013180c99ef90279b0))
##### Dependencies
- [`engine.io@~6.4.1`](https://togithub.com/socketio/engine.io/releases/tag/6.4.1) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.0...6.4.1))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.0`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#460-2023-02-07)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.4...4.6.0)
##### Bug Fixes
- add timeout method to remote socket ([#4558](https://togithub.com/socketio/socket.io/issues/4558)) ([0c0eb00](https://togithub.com/socketio/socket.io/commit/0c0eb0016317218c2be3641e706cfaa9bea39a2d))
- **typings:** properly type emits with timeout ([f3ada7d](https://togithub.com/socketio/socket.io/commit/f3ada7d8ccc02eeced2b9b9ac8e4bc921eb630d2))
##### Features
##### Promise-based acknowledgements
This commit adds some syntactic sugar around acknowledgements:
- `emitWithAck()`
```js
try {
const responses = await io.timeout(1000).emitWithAck("some-event");
console.log(responses); // one response per client
} catch (e) {
// some clients did not acknowledge the event in the given delay
}
io.on("connection", async (socket) => {
// without timeout
const response = await socket.emitWithAck("hello", "world");
// with a specific timeout
try {
const response = await socket.timeout(1000).emitWithAck("hello", "world");
} catch (err) {
// the client did not acknowledge the event in the given delay
}
});
```
- `serverSideEmitWithAck()`
```js
try {
const responses = await io.timeout(1000).serverSideEmitWithAck("some-event");
console.log(responses); // one response per server (except itself)
} catch (e) {
// some servers did not acknowledge the event in the given delay
}
```
Added in [184f3cf](https://togithub.com/socketio/socket.io/commit/184f3cf7af57acc4b0948eee307f25f8536eb6c8).
##### Connection state recovery
This feature allows a client to reconnect after a temporary disconnection and restore its state:
- id
- rooms
- data
- missed packets
Usage:
```js
import { Server } from "socket.io";
const io = new Server({
connectionStateRecovery: {
// default values
maxDisconnectionDuration: 2 * 60 * 1000,
skipMiddlewares: true,
},
});
io.on("connection", (socket) => {
console.log(socket.recovered); // whether the state was recovered or not
});
```
Here's how it works:
- the server sends a session ID during the handshake (which is different from the current `id` attribute, which is public and can be freely shared)
- the server also includes an offset in each packet (added at the end of the data array, for backward compatibility)
- upon temporary disconnection, the server stores the client state for a given delay (implemented at the adapter level)
- upon reconnection, the client sends both the session ID and the last offset it has processed, and the server tries to restore the state
The in-memory adapter already supports this feature, and we will soon update the Postgres and MongoDB adapters. We will also create a new adapter based on [Redis Streams](https://redis.io/docs/data-types/streams/), which will support this feature.
Added in [54d5ee0](https://togithub.com/socketio/socket.io/commit/54d5ee05a684371191e207b8089f09fc24eb5107).
##### Compatibility (for real) with Express middlewares
This feature implements middlewares at the Engine.IO level, because Socket.IO middlewares are meant for namespace authorization and are not executed during a classic HTTP request/response cycle.
Syntax:
```js
io.engine.use((req, res, next) => {
// do something
next();
});
// with express-session
import session from "express-session";
io.engine.use(session({
secret: "keyboard cat",
resave: false,
saveUninitialized: true,
cookie: { secure: true }
}));
// with helmet
import helmet from "helmet";
io.engine.use(helmet());
```
A workaround was possible by using the allowRequest option and the "headers" event, but this feels way cleaner and works with upgrade requests too.
Added in [24786e7](https://togithub.com/socketio/engine.io/commit/24786e77c5403b1c4b5a2bc84e2af06f9187f74a).
##### Error details in the disconnecting and disconnect events
The `disconnect` event will now contain additional details about the disconnection reason.
```js
io.on("connection", (socket) => {
socket.on("disconnect", (reason, description) => {
console.log(description);
});
});
```
Added in [8aa9499](https://togithub.com/socketio/socket.io/commit/8aa94991cee5518567d6254eec04b23f81510257).
##### Automatic removal of empty child namespaces
This commit adds a new option, "cleanupEmptyChildNamespaces". With this option enabled (disabled by default), when a socket disconnects from a dynamic namespace and if there are no other sockets connected to it then the namespace will be cleaned up and its adapter will be closed.
```js
import { createServer } from "node:http";
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer, {
cleanupEmptyChildNamespaces: true
});
```
Added in [5d9220b](https://togithub.com/socketio/socket.io/commit/5d9220b69adf73e086c27bbb63a4976b348f7c4c).
##### A new "addTrailingSlash" option
The trailing slash which was added by default can now be disabled:
```js
import { createServer } from "node:http";
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer, {
addTrailingSlash: false
});
```
In the example above, the clients can omit the trailing slash and use `/socket.io` instead of `/socket.io/`.
Added in [d0fd474](https://togithub.com/socketio/engine.io/commit/d0fd4746afa396297f07bb62e539b0c1c4018d7c).
##### Performance Improvements
- precompute the WebSocket frames when broadcasting ([da2b542](https://togithub.com/socketio/socket.io/commit/da2b54279749adc5279c9ac4742b01b36c01cff0))
##### Dependencies
- [`engine.io@~6.4.0`](https://togithub.com/socketio/engine.io/releases/tag/6.4.0) (https://github.com/socketio/engine.io/compare/6.2.1...6.4.0)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (https://github.com/websockets/ws/compare/8.2.3...8.11.0)
### [`v4.5.4`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#454-2022-11-22)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.3...4.5.4)
This release contains a bump of:
- `engine.io` in order to fix [CVE-2022-41940](https://togithub.com/socketio/engine.io/security/advisories/GHSA-r7qp-cfhv-p84w)
- `socket.io-parser` in order to fix [CVE-2022-2421](https://togithub.com/advisories/GHSA-qm95-pgcg-qqfq).
##### Dependencies
- [`engine.io@~6.2.1`](https://togithub.com/socketio/engine.io/releases/tag/6.2.1) ([diff](https://togithub.com/socketio/engine.io/compare/6.2.0...6.2.1))
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
### [`v4.5.3`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#453-2022-10-15)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.2...4.5.3)
##### Bug Fixes
- **typings:** accept an HTTP2 server in the constructor ([d3d0a2d](https://togithub.com/socketio/socket.io/commit/d3d0a2d5beaff51fd145f810bcaf6914213f8a06))
- **typings:** apply types to "io.timeout(...).emit()" calls ([e357daf](https://togithub.com/socketio/socket.io/commit/e357daf5858560bc84e7e50cd36f0278d6721ea1))
##### Dependencies
- [`engine.io@~6.2.0`](https://togithub.com/socketio/engine.io/releases/tag/6.2.1) (no change)
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
### [`v4.5.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#452-2022-09-02)
[Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.1...4.5.2)
##### Bug Fixes
- prevent the socket from joining a room after disconnection ([18f3fda](https://togithub.com/socketio/socket.io/commit/18f3fdab12947a9fee3e9c37cfc1da97027d1473))
- **uws:** prevent the server from crashing after upgrade ([ba497ee](https://togithub.com/socketio/socket.io/commit/ba497ee3eb52c4abf1464380d015d8c788714364))
##### Dependencies
- [`engine.io@~6.2.0`](https://togithub.com/socketio/engine.io/releases/tag/6.2.0) (no change)
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
socketio/socket.io-client (socket.io-client)
### [`v4.7.5`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#475-2024-03-14)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.4...4.7.5)
##### Bug Fixes
- discard acknowledgements upon disconnection ([34cbfbb](https://togithub.com/socketio/socket.io-client/commit/34cbfbb532ae333f4dd034138e8f87cb80a8e382))
##### Dependencies
- [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.4`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#474-2024-01-12)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.3...4.7.4)
There were some minor bug fixes on the server side, which mandate a client bump.
##### Dependencies
- [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.3`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#473-2024-01-03)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.2...4.7.3)
##### Bug Fixes
- improve compatibility with node16 module resolution ([#1595](https://togithub.com/socketio/socket.io-client/issues/1595)) ([605de78](https://togithub.com/socketio/socket.io-client/commit/605de78d2cd7303bf25d9e2146e2b707dbf63d4f))
- **typings:** accept string | undefined as init argument ([5a3eafe](https://togithub.com/socketio/socket.io-client/commit/5a3eafed1c4118ac3a06ec81a24491eec7d0655f))
- **typings:** fix the type of the socket#id attribute ([f9c16f2](https://togithub.com/socketio/socket.io-client/commit/f9c16f226512fc8a8df461e3a07e392720462165))
##### Dependencies
- [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#472-2023-08-02)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.1...4.7.2)
Some bug fixes are included from the `engine.io-client` package:
- **webtransport:** add proper framing ([d55c39e](https://togithub.com/socketio/engine.io-client/commit/d55c39e0ed5cb7b3a34875a398efc111c91184f6))
- **webtransport:** honor the binaryType attribute ([8270e00](https://togithub.com/socketio/engine.io-client/commit/8270e00d5b865278d136a4d349b344cbc2b38dc5))
##### Dependencies
- [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.5.1...6.5.2))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.1`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#471-2023-06-28)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.0...4.7.1)
Some bug fixes are included from the `engine.io-client` package:
- make closeOnBeforeunload default to false ([a63066b](https://togithub.com/socketio/engine.io-client/commit/a63066bdc8ae9e6746c3113d06c2ead78f4a4851))
- **webtransport:** properly handle abruptly closed connections ([cf6aa1f](https://togithub.com/socketio/engine.io-client/commit/cf6aa1f43c27a56c076bf26fddfce74bfeb65040))
##### Dependencies
- [`engine.io-client@~6.5.1`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.1) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.5.0...6.5.1))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.7.0`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#470-2023-06-22)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.2...4.7.0)
##### Bug Fixes
- properly report timeout error when connecting ([5bc94b5](https://togithub.com/socketio/socket.io-client/commit/5bc94b56bc1788bab16d9d514d2c8abf3b1d8f87))
- use same scope for setTimeout and clearTimeout calls ([#1568](https://togithub.com/socketio/socket.io-client/issues/1568)) ([f2892ab](https://togithub.com/socketio/socket.io-client/commit/f2892aba0beeae7c9be930221655d7da6094c5f1))
##### 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](https://togithub.com/nodejs/node/issues/38478), you can use the `@fails-components/webtransport` package:
```js
import { WebTransport } from "@fails-components/webtransport";
global.WebTransport = WebTransport;
```
Added in [7195c0f](https://togithub.com/socketio/engine.io-client/commit/7195c0f305b482f7b1ca2ed812030caaf72c0906).
##### 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.
```js
import { io } from "socket.io-client";
const socket = io("https://example.com", {
withCredentials: true
});
```
Added in [5fc88a6](https://togithub.com/socketio/engine.io-client/commit/5fc88a62d4017cdc144fa39b9755deadfff2db34).
##### Conditional import of the ESM build with debug logs
By default, the ESM build does not include the `debug` package in the browser environments, because it increases the bundle size (see [16b6569](https://togithub.com/socketio/socket.io-client/commit/16b65698aed766e1e645c78847f2e91bfc5b6f56)).
Which means that, unfortunately, debug logs are not available in the devtools console, even when setting the `localStorage.debug = ...` attribute.
You can now import the build which includes the `debug` packages with a [conditional import](https://nodejs.org/api/packages.html#conditional-exports). Example with vite:
```js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 4000
},
resolve: {
conditions: ["development"]
}
})
```
Reference: https://v2.vitejs.dev/config/#resolve-conditions
Added in [781d753](https://togithub.com/socketio/socket.io-client/commit/781d753a626d01e675056a2ff4e27f5dd599564f).
##### Dependencies
- [`engine.io-client@~6.5.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.0) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.4.0...6.5.0))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#462-2023-05-31)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.1...4.6.2)
##### Bug Fixes
- **exports:** move `types` condition to the top ([#1580](https://togithub.com/socketio/socket.io-client/issues/1580)) ([7ead241](https://togithub.com/socketio/socket.io-client/commit/7ead241ecfd9f122db6789b5f2d11c04e9427953))
##### Dependencies
- [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.1`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#461-2023-02-20)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.0...4.6.1)
##### Bug Fixes
- do not drain the queue while the socket is offline ([4996f9e](https://togithub.com/socketio/socket.io-client/commit/4996f9ee71074e2d62a0f8fa95fcf7d43e99615d))
- prevent duplicate connections when multiplexing ([46213a6](https://togithub.com/socketio/socket.io-client/commit/46213a647ea0d4453b00bca09268f69ffd259509))
##### Dependencies
- [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) (no change)
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change)
### [`v4.6.0`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#460-2023-02-07)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.4...4.6.0)
##### Bug Fixes
- **typings:** do not expose browser-specific types ([4d6d95e](https://togithub.com/socketio/socket.io-client/commit/4d6d95e0792efd43b78c760b055764fef02ebc9e))
- ensure manager.socket() returns an active socket ([b7dd891](https://togithub.com/socketio/socket.io-client/commit/b7dd891e890461d33a104ca9187d5cd30d6f76af))
- **typings:** properly type emits with timeout ([#1570](https://togithub.com/socketio/socket.io-client/issues/1570)) ([33e4172](https://togithub.com/socketio/socket.io-client/commit/33e417258c9a5697e001163971ae87821e9c097f))
##### Features
##### A new "addTrailingSlash" option
The trailing slash which was added by default can now be disabled:
```js
import { io } from "socket.io-client";
const socket = io("https://example.com", {
addTrailingSlash: false
});
```
In the example above, the request URL will be `https://example.com/socket.io` instead of `https://example.com/socket.io/`.
Added in [21a6e12](https://togithub.com/socketio/engine.io-client/commit/21a6e1219add92157c5442537d24fbe1129a50f5).
##### Promise-based acknowledgements
This commit adds some syntactic sugar around acknowledgements:
```js
// without timeout
const response = await socket.emitWithAck("hello", "world");
// with a specific timeout
try {
const response = await socket.timeout(1000).emitWithAck("hello", "world");
} catch (err) {
// the server did not acknowledge the event in the given delay
}
```
Note: environments that [do not support Promises](https://caniuse.com/promises) will need to add a polyfill in order to use this feature.
Added in [47b979d](https://togithub.com/socketio/socket.io-client/commit/47b979d57388e9b5e9a332f3f4a9873211f0d844).
##### Connection state recovery
This feature allows a client to reconnect after a temporary disconnection and restore its ID and receive any packets that was missed during the disconnection gap. It must be enabled on the server side.
A new boolean attribute named `recovered` is added on the `socket` object:
```js
socket.on("connect", () => {
console.log(socket.recovered); // whether the recovery was successful
});
```
Added in [54d5ee0](https://togithub.com/socketio/socket.io/commit/54d5ee05a684371191e207b8089f09fc24eb5107) (server) and [b4e20c5](https://togithub.com/socketio/socket.io-client/commit/b4e20c5c709b5e9cc03ee9b6bd1d576f4810a817) (client).
##### Retry mechanism
Two new options are available:
- `retries`: the maximum number of retries. Above the limit, the packet will be discarded.
- `ackTimeout`: the default timeout in milliseconds used when waiting for an acknowledgement (not to be mixed up with the already existing `timeout` option, which is used by the Manager during the connection)
```js
const socket = io({
retries: 3,
ackTimeout: 10000
});
// implicit ack
socket.emit("my-event");
// explicit ack
socket.emit("my-event", (err, val) => { /* ... */ });
// custom timeout (in that case the ackTimeout is optional)
socket.timeout(5000).emit("my-event", (err, val) => { /* ... */ });
```
In all examples above, "my-event" will be sent up to 4 times (1 + 3), until the server sends an acknowledgement.
Assigning a unique ID to each packet is the duty of the user, in order to allow deduplication on the server side.
Added in [655dce9](https://togithub.com/socketio/socket.io-client/commit/655dce97556a1ea44a60db6b694d0cfd85b5f70f).
##### Dependencies
- [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.2.3...6.4.0))
- [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) ([diff](https://togithub.com/websockets/ws/compare/8.2.3...8.11.0))
### [`v4.5.4`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#454-2022-11-22)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.3...4.5.4)
This release contains a bump of the `socket.io-parser` dependency, in order to fix [CVE-2022-2421](https://togithub.com/advisories/GHSA-qm95-pgcg-qqfq).
##### Dependencies
- [`engine.io-client@~6.2.3`](https://togithub.com/socketio/engine.io-client/tree/6.2.3) (no change)
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
### [`v4.5.3`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#453-2022-10-15)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.2...4.5.3)
##### Bug Fixes
- do not swallow user exceptions ([2403b88](https://togithub.com/socketio/socket.io-client/commit/2403b88057bf3fd32eb2047c82be26c455c13a2f))
##### Dependencies
- [`engine.io-client@~6.2.3`](https://togithub.com/socketio/engine.io-client/tree/6.2.3) (https://github.com/socketio/engine.io-client/compare/6.2.1...6.2.3)
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
### [`v4.5.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#452-2022-09-02)
[Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.1...4.5.2)
##### Bug Fixes
- handle ill-formatted packet from server ([c597023](https://togithub.com/socketio/socket.io-client/commit/c5970231699aa47b00c4a617af4239d0fa90fa53))
##### Dependencies
- [`engine.io-client@~6.2.1`](https://togithub.com/socketio/engine.io-client/releases/tag/6.2.1) (no change)
- [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)
Configuration
📅 Schedule: Branch creation - "before 4am" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
4.5.1
->4.7.5
4.5.1
->4.7.5
Release Notes
socketio/socket.io (socket.io)
### [`v4.7.5`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#475-2024-03-14) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.4...4.7.5) ##### Bug Fixes - close the adapters when the server is closed ([bf64870](https://togithub.com/socketio/socket.io/commit/bf64870957e626a73e0544716a1a41a4ba5093bb)) - remove duplicate pipeline when serving bundle ([e426f3e](https://togithub.com/socketio/socket.io/commit/e426f3e8e1bfea5720c32d30a3663303200ee6ad)) ##### Dependencies - [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.4`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#474-2024-01-12) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.3...4.7.4) ##### Bug Fixes - **typings:** calling io.emit with no arguments incorrectly errored ([cb6d2e0](https://togithub.com/socketio/socket.io/commit/cb6d2e02aa7ec03c2de1817d35cffa1128b107ef)), closes [#4914](https://togithub.com/socketio/socket.io/issues/4914) ##### Dependencies - [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.3`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#473-2024-01-03) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.2...4.7.3) ##### Bug Fixes - return the first response when broadcasting to a single socket ([#4878](https://togithub.com/socketio/socket.io/issues/4878)) ([df8e70f](https://togithub.com/socketio/socket.io/commit/df8e70f79822e3887b4f21ca718af8a53bbda2c4)) - **typings:** allow to bind to a non-secure Http2Server ([#4853](https://togithub.com/socketio/socket.io/issues/4853)) ([8c9ebc3](https://togithub.com/socketio/socket.io/commit/8c9ebc30e5452ff9381af5d79f547394fa55633c)) ##### Dependencies - [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#472-2023-08-02) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.1...4.7.2) ##### Bug Fixes - clean up child namespace when client is rejected in middleware ([#4773](https://togithub.com/socketio/socket.io/issues/4773)) ([0731c0d](https://togithub.com/socketio/socket.io/commit/0731c0d2f497d5cce596ea1ec32a67c08bcccbcd)) - **webtransport:** properly handle WebTransport-only connections ([3468a19](https://togithub.com/socketio/socket.io/commit/3468a197afe87e65eb0d779fabd347fe683013ab)) - **webtransport:** add proper framing ([a306db0](https://togithub.com/socketio/engine.io/commit/a306db09e8ddb367c7d62f45fec920f979580b7c)) ##### Dependencies - [`engine.io@~6.5.2`](https://togithub.com/socketio/engine.io/releases/tag/6.5.2) ([diff](https://togithub.com/socketio/engine.io/compare/6.5.0...6.5.2)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.1`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#471-2023-06-28) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.7.0...4.7.1) The client bundle contains a few fixes regarding the WebTransport support. ##### Dependencies - [`engine.io@~6.5.0`](https://togithub.com/socketio/engine.io/releases/tag/6.5.0) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.0`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#470-2023-06-22) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.2...4.7.0) ##### Bug Fixes - remove the Partial modifier from the socket.data type ([#4740](https://togithub.com/socketio/socket.io/issues/4740)) ([e5c62ca](https://togithub.com/socketio/socket.io/commit/e5c62cad60fc7d16fbb024fd9be1d1880f4e6f5f)) ##### Features ##### Support for WebTransport The Socket.IO server 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/ Until WebTransport support lands [in Node.js](https://togithub.com/nodejs/node/issues/38478), you can use the `@fails-components/webtransport` package: ```js import { readFileSync } from "fs"; import { createServer } from "https"; import { Server } from "socket.io"; import { Http3Server } from "@fails-components/webtransport"; // WARNING: the total length of the validity period MUST NOT exceed two weeks (https://w3c.github.io/webtransport/#custom-certificate-requirements) const cert = readFileSync("/path/to/my/cert.pem"); const key = readFileSync("/path/to/my/key.pem"); const httpsServer = createServer({ key, cert }); httpsServer.listen(3000); const io = new Server(httpsServer, { transports: ["polling", "websocket", "webtransport"] // WebTransport is not enabled by default }); const h3Server = new Http3Server({ port: 3000, host: "0.0.0.0", secret: "changeit", cert, privKey: key, }); (async () => { const stream = await h3Server.sessionStream("/socket.io/"); const sessionReader = stream.getReader(); while (true) { const { done, value } = await sessionReader.read(); if (done) { break; } io.engine.onWebTransportSession(value); } })(); h3Server.startServer(); ``` Added in [123b68c](https://togithub.com/socketio/engine.io/commit/123b68c04f9e971f59b526e0f967a488ee6b0116). ##### Client bundles with CORS headers The bundles will now have the right `Access-Control-Allow-xxx` headers. Added in [63f181c](https://togithub.com/socketio/socket.io/commit/63f181cc12cbbbf94ed40eef52d60f36a1214fbe). ##### Dependencies - [`engine.io@~6.5.0`](https://togithub.com/socketio/engine.io/releases/tag/6.5.0) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.2...6.5.0)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#462-2023-05-31) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.1...4.6.2) ##### Bug Fixes - **exports:** move `types` condition to the top ([#4698](https://togithub.com/socketio/socket.io/issues/4698)) ([3d44aae](https://togithub.com/socketio/socket.io/commit/3d44aae381af38349fdb808d510d9f47a0c2507e)) ##### Dependencies - [`engine.io@~6.4.2`](https://togithub.com/socketio/engine.io/releases/tag/6.4.0) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.1...6.4.2)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.1`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#461-2023-02-20) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.6.0...4.6.1) ##### Bug Fixes - properly handle manually created dynamic namespaces ([0d0a7a2](https://togithub.com/socketio/socket.io/commit/0d0a7a22b5ff95f864216c529114b7dd41738d1e)) - **types:** fix nodenext module resolution compatibility ([#4625](https://togithub.com/socketio/socket.io/issues/4625)) ([d0b22c6](https://togithub.com/socketio/socket.io/commit/d0b22c630208669aceb7ae013180c99ef90279b0)) ##### Dependencies - [`engine.io@~6.4.1`](https://togithub.com/socketio/engine.io/releases/tag/6.4.1) ([diff](https://togithub.com/socketio/engine.io/compare/6.4.0...6.4.1)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.0`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#460-2023-02-07) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.4...4.6.0) ##### Bug Fixes - add timeout method to remote socket ([#4558](https://togithub.com/socketio/socket.io/issues/4558)) ([0c0eb00](https://togithub.com/socketio/socket.io/commit/0c0eb0016317218c2be3641e706cfaa9bea39a2d)) - **typings:** properly type emits with timeout ([f3ada7d](https://togithub.com/socketio/socket.io/commit/f3ada7d8ccc02eeced2b9b9ac8e4bc921eb630d2)) ##### Features ##### Promise-based acknowledgements This commit adds some syntactic sugar around acknowledgements: - `emitWithAck()` ```js try { const responses = await io.timeout(1000).emitWithAck("some-event"); console.log(responses); // one response per client } catch (e) { // some clients did not acknowledge the event in the given delay } io.on("connection", async (socket) => { // without timeout const response = await socket.emitWithAck("hello", "world"); // with a specific timeout try { const response = await socket.timeout(1000).emitWithAck("hello", "world"); } catch (err) { // the client did not acknowledge the event in the given delay } }); ``` - `serverSideEmitWithAck()` ```js try { const responses = await io.timeout(1000).serverSideEmitWithAck("some-event"); console.log(responses); // one response per server (except itself) } catch (e) { // some servers did not acknowledge the event in the given delay } ``` Added in [184f3cf](https://togithub.com/socketio/socket.io/commit/184f3cf7af57acc4b0948eee307f25f8536eb6c8). ##### Connection state recovery This feature allows a client to reconnect after a temporary disconnection and restore its state: - id - rooms - data - missed packets Usage: ```js import { Server } from "socket.io"; const io = new Server({ connectionStateRecovery: { // default values maxDisconnectionDuration: 2 * 60 * 1000, skipMiddlewares: true, }, }); io.on("connection", (socket) => { console.log(socket.recovered); // whether the state was recovered or not }); ``` Here's how it works: - the server sends a session ID during the handshake (which is different from the current `id` attribute, which is public and can be freely shared) - the server also includes an offset in each packet (added at the end of the data array, for backward compatibility) - upon temporary disconnection, the server stores the client state for a given delay (implemented at the adapter level) - upon reconnection, the client sends both the session ID and the last offset it has processed, and the server tries to restore the state The in-memory adapter already supports this feature, and we will soon update the Postgres and MongoDB adapters. We will also create a new adapter based on [Redis Streams](https://redis.io/docs/data-types/streams/), which will support this feature. Added in [54d5ee0](https://togithub.com/socketio/socket.io/commit/54d5ee05a684371191e207b8089f09fc24eb5107). ##### Compatibility (for real) with Express middlewares This feature implements middlewares at the Engine.IO level, because Socket.IO middlewares are meant for namespace authorization and are not executed during a classic HTTP request/response cycle. Syntax: ```js io.engine.use((req, res, next) => { // do something next(); }); // with express-session import session from "express-session"; io.engine.use(session({ secret: "keyboard cat", resave: false, saveUninitialized: true, cookie: { secure: true } })); // with helmet import helmet from "helmet"; io.engine.use(helmet()); ``` A workaround was possible by using the allowRequest option and the "headers" event, but this feels way cleaner and works with upgrade requests too. Added in [24786e7](https://togithub.com/socketio/engine.io/commit/24786e77c5403b1c4b5a2bc84e2af06f9187f74a). ##### Error details in the disconnecting and disconnect events The `disconnect` event will now contain additional details about the disconnection reason. ```js io.on("connection", (socket) => { socket.on("disconnect", (reason, description) => { console.log(description); }); }); ``` Added in [8aa9499](https://togithub.com/socketio/socket.io/commit/8aa94991cee5518567d6254eec04b23f81510257). ##### Automatic removal of empty child namespaces This commit adds a new option, "cleanupEmptyChildNamespaces". With this option enabled (disabled by default), when a socket disconnects from a dynamic namespace and if there are no other sockets connected to it then the namespace will be cleaned up and its adapter will be closed. ```js import { createServer } from "node:http"; import { Server } from "socket.io"; const httpServer = createServer(); const io = new Server(httpServer, { cleanupEmptyChildNamespaces: true }); ``` Added in [5d9220b](https://togithub.com/socketio/socket.io/commit/5d9220b69adf73e086c27bbb63a4976b348f7c4c). ##### A new "addTrailingSlash" option The trailing slash which was added by default can now be disabled: ```js import { createServer } from "node:http"; import { Server } from "socket.io"; const httpServer = createServer(); const io = new Server(httpServer, { addTrailingSlash: false }); ``` In the example above, the clients can omit the trailing slash and use `/socket.io` instead of `/socket.io/`. Added in [d0fd474](https://togithub.com/socketio/engine.io/commit/d0fd4746afa396297f07bb62e539b0c1c4018d7c). ##### Performance Improvements - precompute the WebSocket frames when broadcasting ([da2b542](https://togithub.com/socketio/socket.io/commit/da2b54279749adc5279c9ac4742b01b36c01cff0)) ##### Dependencies - [`engine.io@~6.4.0`](https://togithub.com/socketio/engine.io/releases/tag/6.4.0) (https://github.com/socketio/engine.io/compare/6.2.1...6.4.0) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (https://github.com/websockets/ws/compare/8.2.3...8.11.0) ### [`v4.5.4`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#454-2022-11-22) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.3...4.5.4) This release contains a bump of: - `engine.io` in order to fix [CVE-2022-41940](https://togithub.com/socketio/engine.io/security/advisories/GHSA-r7qp-cfhv-p84w) - `socket.io-parser` in order to fix [CVE-2022-2421](https://togithub.com/advisories/GHSA-qm95-pgcg-qqfq). ##### Dependencies - [`engine.io@~6.2.1`](https://togithub.com/socketio/engine.io/releases/tag/6.2.1) ([diff](https://togithub.com/socketio/engine.io/compare/6.2.0...6.2.1)) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change) ### [`v4.5.3`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#453-2022-10-15) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.2...4.5.3) ##### Bug Fixes - **typings:** accept an HTTP2 server in the constructor ([d3d0a2d](https://togithub.com/socketio/socket.io/commit/d3d0a2d5beaff51fd145f810bcaf6914213f8a06)) - **typings:** apply types to "io.timeout(...).emit()" calls ([e357daf](https://togithub.com/socketio/socket.io/commit/e357daf5858560bc84e7e50cd36f0278d6721ea1)) ##### Dependencies - [`engine.io@~6.2.0`](https://togithub.com/socketio/engine.io/releases/tag/6.2.1) (no change) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change) ### [`v4.5.2`](https://togithub.com/socketio/socket.io/blob/HEAD/CHANGELOG.md#452-2022-09-02) [Compare Source](https://togithub.com/socketio/socket.io/compare/4.5.1...4.5.2) ##### Bug Fixes - prevent the socket from joining a room after disconnection ([18f3fda](https://togithub.com/socketio/socket.io/commit/18f3fdab12947a9fee3e9c37cfc1da97027d1473)) - **uws:** prevent the server from crashing after upgrade ([ba497ee](https://togithub.com/socketio/socket.io/commit/ba497ee3eb52c4abf1464380d015d8c788714364)) ##### Dependencies - [`engine.io@~6.2.0`](https://togithub.com/socketio/engine.io/releases/tag/6.2.0) (no change) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)socketio/socket.io-client (socket.io-client)
### [`v4.7.5`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#475-2024-03-14) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.4...4.7.5) ##### Bug Fixes - discard acknowledgements upon disconnection ([34cbfbb](https://togithub.com/socketio/socket.io-client/commit/34cbfbb532ae333f4dd034138e8f87cb80a8e382)) ##### Dependencies - [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.4`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#474-2024-01-12) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.3...4.7.4) There were some minor bug fixes on the server side, which mandate a client bump. ##### Dependencies - [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.3`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#473-2024-01-03) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.2...4.7.3) ##### Bug Fixes - improve compatibility with node16 module resolution ([#1595](https://togithub.com/socketio/socket.io-client/issues/1595)) ([605de78](https://togithub.com/socketio/socket.io-client/commit/605de78d2cd7303bf25d9e2146e2b707dbf63d4f)) - **typings:** accept string | undefined as init argument ([5a3eafe](https://togithub.com/socketio/socket.io-client/commit/5a3eafed1c4118ac3a06ec81a24491eec7d0655f)) - **typings:** fix the type of the socket#id attribute ([f9c16f2](https://togithub.com/socketio/socket.io-client/commit/f9c16f226512fc8a8df461e3a07e392720462165)) ##### Dependencies - [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#472-2023-08-02) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.1...4.7.2) Some bug fixes are included from the `engine.io-client` package: - **webtransport:** add proper framing ([d55c39e](https://togithub.com/socketio/engine.io-client/commit/d55c39e0ed5cb7b3a34875a398efc111c91184f6)) - **webtransport:** honor the binaryType attribute ([8270e00](https://togithub.com/socketio/engine.io-client/commit/8270e00d5b865278d136a4d349b344cbc2b38dc5)) ##### Dependencies - [`engine.io-client@~6.5.2`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.2) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.5.1...6.5.2)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.1`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#471-2023-06-28) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.7.0...4.7.1) Some bug fixes are included from the `engine.io-client` package: - make closeOnBeforeunload default to false ([a63066b](https://togithub.com/socketio/engine.io-client/commit/a63066bdc8ae9e6746c3113d06c2ead78f4a4851)) - **webtransport:** properly handle abruptly closed connections ([cf6aa1f](https://togithub.com/socketio/engine.io-client/commit/cf6aa1f43c27a56c076bf26fddfce74bfeb65040)) ##### Dependencies - [`engine.io-client@~6.5.1`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.1) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.5.0...6.5.1)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.7.0`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#470-2023-06-22) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.2...4.7.0) ##### Bug Fixes - properly report timeout error when connecting ([5bc94b5](https://togithub.com/socketio/socket.io-client/commit/5bc94b56bc1788bab16d9d514d2c8abf3b1d8f87)) - use same scope for setTimeout and clearTimeout calls ([#1568](https://togithub.com/socketio/socket.io-client/issues/1568)) ([f2892ab](https://togithub.com/socketio/socket.io-client/commit/f2892aba0beeae7c9be930221655d7da6094c5f1)) ##### 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](https://togithub.com/nodejs/node/issues/38478), you can use the `@fails-components/webtransport` package: ```js import { WebTransport } from "@fails-components/webtransport"; global.WebTransport = WebTransport; ``` Added in [7195c0f](https://togithub.com/socketio/engine.io-client/commit/7195c0f305b482f7b1ca2ed812030caaf72c0906). ##### 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. ```js import { io } from "socket.io-client"; const socket = io("https://example.com", { withCredentials: true }); ``` Added in [5fc88a6](https://togithub.com/socketio/engine.io-client/commit/5fc88a62d4017cdc144fa39b9755deadfff2db34). ##### Conditional import of the ESM build with debug logs By default, the ESM build does not include the `debug` package in the browser environments, because it increases the bundle size (see [16b6569](https://togithub.com/socketio/socket.io-client/commit/16b65698aed766e1e645c78847f2e91bfc5b6f56)). Which means that, unfortunately, debug logs are not available in the devtools console, even when setting the `localStorage.debug = ...` attribute. You can now import the build which includes the `debug` packages with a [conditional import](https://nodejs.org/api/packages.html#conditional-exports). Example with vite: ```js import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], server: { port: 4000 }, resolve: { conditions: ["development"] } }) ``` Reference: https://v2.vitejs.dev/config/#resolve-conditions Added in [781d753](https://togithub.com/socketio/socket.io-client/commit/781d753a626d01e675056a2ff4e27f5dd599564f). ##### Dependencies - [`engine.io-client@~6.5.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.5.0) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.4.0...6.5.0)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#462-2023-05-31) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.1...4.6.2) ##### Bug Fixes - **exports:** move `types` condition to the top ([#1580](https://togithub.com/socketio/socket.io-client/issues/1580)) ([7ead241](https://togithub.com/socketio/socket.io-client/commit/7ead241ecfd9f122db6789b5f2d11c04e9427953)) ##### Dependencies - [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.1`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#461-2023-02-20) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.6.0...4.6.1) ##### Bug Fixes - do not drain the queue while the socket is offline ([4996f9e](https://togithub.com/socketio/socket.io-client/commit/4996f9ee71074e2d62a0f8fa95fcf7d43e99615d)) - prevent duplicate connections when multiplexing ([46213a6](https://togithub.com/socketio/socket.io-client/commit/46213a647ea0d4453b00bca09268f69ffd259509)) ##### Dependencies - [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) (no change) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) (no change) ### [`v4.6.0`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#460-2023-02-07) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.4...4.6.0) ##### Bug Fixes - **typings:** do not expose browser-specific types ([4d6d95e](https://togithub.com/socketio/socket.io-client/commit/4d6d95e0792efd43b78c760b055764fef02ebc9e)) - ensure manager.socket() returns an active socket ([b7dd891](https://togithub.com/socketio/socket.io-client/commit/b7dd891e890461d33a104ca9187d5cd30d6f76af)) - **typings:** properly type emits with timeout ([#1570](https://togithub.com/socketio/socket.io-client/issues/1570)) ([33e4172](https://togithub.com/socketio/socket.io-client/commit/33e417258c9a5697e001163971ae87821e9c097f)) ##### Features ##### A new "addTrailingSlash" option The trailing slash which was added by default can now be disabled: ```js import { io } from "socket.io-client"; const socket = io("https://example.com", { addTrailingSlash: false }); ``` In the example above, the request URL will be `https://example.com/socket.io` instead of `https://example.com/socket.io/`. Added in [21a6e12](https://togithub.com/socketio/engine.io-client/commit/21a6e1219add92157c5442537d24fbe1129a50f5). ##### Promise-based acknowledgements This commit adds some syntactic sugar around acknowledgements: ```js // without timeout const response = await socket.emitWithAck("hello", "world"); // with a specific timeout try { const response = await socket.timeout(1000).emitWithAck("hello", "world"); } catch (err) { // the server did not acknowledge the event in the given delay } ``` Note: environments that [do not support Promises](https://caniuse.com/promises) will need to add a polyfill in order to use this feature. Added in [47b979d](https://togithub.com/socketio/socket.io-client/commit/47b979d57388e9b5e9a332f3f4a9873211f0d844). ##### Connection state recovery This feature allows a client to reconnect after a temporary disconnection and restore its ID and receive any packets that was missed during the disconnection gap. It must be enabled on the server side. A new boolean attribute named `recovered` is added on the `socket` object: ```js socket.on("connect", () => { console.log(socket.recovered); // whether the recovery was successful }); ``` Added in [54d5ee0](https://togithub.com/socketio/socket.io/commit/54d5ee05a684371191e207b8089f09fc24eb5107) (server) and [b4e20c5](https://togithub.com/socketio/socket.io-client/commit/b4e20c5c709b5e9cc03ee9b6bd1d576f4810a817) (client). ##### Retry mechanism Two new options are available: - `retries`: the maximum number of retries. Above the limit, the packet will be discarded. - `ackTimeout`: the default timeout in milliseconds used when waiting for an acknowledgement (not to be mixed up with the already existing `timeout` option, which is used by the Manager during the connection) ```js const socket = io({ retries: 3, ackTimeout: 10000 }); // implicit ack socket.emit("my-event"); // explicit ack socket.emit("my-event", (err, val) => { /* ... */ }); // custom timeout (in that case the ackTimeout is optional) socket.timeout(5000).emit("my-event", (err, val) => { /* ... */ }); ``` In all examples above, "my-event" will be sent up to 4 times (1 + 3), until the server sends an acknowledgement. Assigning a unique ID to each packet is the duty of the user, in order to allow deduplication on the server side. Added in [655dce9](https://togithub.com/socketio/socket.io-client/commit/655dce97556a1ea44a60db6b694d0cfd85b5f70f). ##### Dependencies - [`engine.io-client@~6.4.0`](https://togithub.com/socketio/engine.io-client/releases/tag/6.4.0) ([diff](https://togithub.com/socketio/engine.io-client/compare/6.2.3...6.4.0)) - [`ws@~8.11.0`](https://togithub.com/websockets/ws/releases/tag/8.11.0) ([diff](https://togithub.com/websockets/ws/compare/8.2.3...8.11.0)) ### [`v4.5.4`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#454-2022-11-22) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.3...4.5.4) This release contains a bump of the `socket.io-parser` dependency, in order to fix [CVE-2022-2421](https://togithub.com/advisories/GHSA-qm95-pgcg-qqfq). ##### Dependencies - [`engine.io-client@~6.2.3`](https://togithub.com/socketio/engine.io-client/tree/6.2.3) (no change) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change) ### [`v4.5.3`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#453-2022-10-15) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.2...4.5.3) ##### Bug Fixes - do not swallow user exceptions ([2403b88](https://togithub.com/socketio/socket.io-client/commit/2403b88057bf3fd32eb2047c82be26c455c13a2f)) ##### Dependencies - [`engine.io-client@~6.2.3`](https://togithub.com/socketio/engine.io-client/tree/6.2.3) (https://github.com/socketio/engine.io-client/compare/6.2.1...6.2.3) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change) ### [`v4.5.2`](https://togithub.com/socketio/socket.io-client/blob/HEAD/CHANGELOG.md#452-2022-09-02) [Compare Source](https://togithub.com/socketio/socket.io-client/compare/4.5.1...4.5.2) ##### Bug Fixes - handle ill-formatted packet from server ([c597023](https://togithub.com/socketio/socket.io-client/commit/c5970231699aa47b00c4a617af4239d0fa90fa53)) ##### Dependencies - [`engine.io-client@~6.2.1`](https://togithub.com/socketio/engine.io-client/releases/tag/6.2.1) (no change) - [`ws@~8.2.3`](https://togithub.com/websockets/ws/releases/tag/8.2.3) (no change)Configuration
📅 Schedule: Branch creation - "before 4am" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by Mend Renovate. View repository job log here.