Skip to content

Commit 5980918

Browse files
chore(release): 4.6.0
Diff: 4.5.4...4.6.0
1 parent dff34a3 commit 5980918

10 files changed

+414
-151
lines changed

CHANGELOG.md

+104-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# History
22

3+
## 2023
4+
5+
- [4.6.0](#460-2023-02-07) (Feb 2023)
6+
37
## 2022
48

59
- [4.5.4](#454-2022-11-22) (Nov 2022)
@@ -53,14 +57,113 @@
5357

5458
# Release notes
5559

60+
# [4.6.0](https://github.com/socketio/socket.io-client/compare/4.5.4...4.6.0) (2023-02-07)
61+
62+
63+
### Bug Fixes
64+
65+
* **typings:** do not expose browser-specific types ([4d6d95e](https://github.com/socketio/socket.io-client/commit/4d6d95e0792efd43b78c760b055764fef02ebc9e))
66+
* ensure manager.socket() returns an active socket ([b7dd891](https://github.com/socketio/socket.io-client/commit/b7dd891e890461d33a104ca9187d5cd30d6f76af))
67+
* **typings:** properly type emits with timeout ([#1570](https://github.com/socketio/socket.io-client/issues/1570)) ([33e4172](https://github.com/socketio/socket.io-client/commit/33e417258c9a5697e001163971ae87821e9c097f))
68+
69+
70+
### Features
71+
72+
#### A new "addTrailingSlash" option
73+
74+
The trailing slash which was added by default can now be disabled:
75+
76+
```js
77+
import { io } from "socket.io-client";
78+
79+
const socket = io("https://example.com", {
80+
addTrailingSlash: false
81+
});
82+
```
83+
84+
In the example above, the request URL will be `https://example.com/socket.io` instead of `https://example.com/socket.io/`.
85+
86+
Added in [21a6e12](https://github.com/socketio/engine.io-client/commit/21a6e1219add92157c5442537d24fbe1129a50f5).
87+
88+
#### Promise-based acknowledgements
89+
90+
This commit adds some syntactic sugar around acknowledgements:
91+
92+
```js
93+
// without timeout
94+
const response = await socket.emitWithAck("hello", "world");
95+
96+
// with a specific timeout
97+
try {
98+
const response = await socket.timeout(1000).emitWithAck("hello", "world");
99+
} catch (err) {
100+
// the server did not acknowledge the event in the given delay
101+
}
102+
```
103+
104+
Note: environments that [do not support Promises](https://caniuse.com/promises) will need to add a polyfill in order to use this feature.
105+
106+
Added in [47b979d](https://github.com/socketio/socket.io-client/commit/47b979d57388e9b5e9a332f3f4a9873211f0d844).
107+
108+
#### Connection state recovery
109+
110+
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.
111+
112+
A new boolean attribute named `recovered` is added on the `socket` object:
113+
114+
```js
115+
socket.on("connect", () => {
116+
console.log(socket.recovered); // whether the recovery was successful
117+
});
118+
```
119+
120+
Added in [54d5ee0](https://github.com/socketio/socket.io/commit/54d5ee05a684371191e207b8089f09fc24eb5107) (server) and [b4e20c5](https://github.com/socketio/socket.io-client/commit/b4e20c5c709b5e9cc03ee9b6bd1d576f4810a817) (client).
121+
122+
#### Retry mechanism
123+
124+
Two new options are available:
125+
126+
- `retries`: the maximum number of retries. Above the limit, the packet will be discarded.
127+
- `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)
128+
129+
```js
130+
const socket = io({
131+
retries: 3,
132+
ackTimeout: 10000
133+
});
134+
135+
// implicit ack
136+
socket.emit("my-event");
137+
138+
// explicit ack
139+
socket.emit("my-event", (err, val) => { /* ... */ });
140+
141+
// custom timeout (in that case the ackTimeout is optional)
142+
socket.timeout(5000).emit("my-event", (err, val) => { /* ... */ });
143+
```
144+
145+
In all examples above, "my-event" will be sent up to 4 times (1 + 3), until the server sends an acknowledgement.
146+
147+
Assigning a unique ID to each packet is the duty of the user, in order to allow deduplication on the server side.
148+
149+
Added in [655dce9](https://github.com/socketio/socket.io-client/commit/655dce97556a1ea44a60db6b694d0cfd85b5f70f).
150+
151+
152+
### Dependencies
153+
154+
- [`engine.io-client@~6.4.0`](https://github.com/socketio/engine.io-client/releases/tag/6.4.0) ([diff](https://github.com/socketio/engine.io-client/compare/6.2.3...6.4.0))
155+
- [`ws@~8.11.0`](https://github.com/websockets/ws/releases/tag/8.11.0) ([diff](https://github.com/websockets/ws/compare/8.2.3...8.11.0))
156+
157+
158+
56159
## [4.5.4](https://github.com/socketio/socket.io-client/compare/4.5.3...4.5.4) (2022-11-22)
57160

58161
This release contains a bump of the `socket.io-parser` dependency, in order to fix [CVE-2022-2421](https://github.com/advisories/GHSA-qm95-pgcg-qqfq).
59162

60163
### Dependencies
61164

62165
- [`engine.io-client@~6.2.3`](https://github.com/socketio/engine.io-client/tree/6.2.3)
63-
- [`ws@~8.2.3`](https://github.com/websockets/ws/releases/tag/8.2.3)
166+
- [`ws@~8.2.3`](https://github.com/websockets/ws/releases/tag/8.2.3) (no change)
64167

65168

66169

dist/socket.io.esm.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/socket.io.esm.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)