|
2 | 2 |
|
3 | 3 | | Version | Release date | Bundle size (UMD min+gzip) |
|
4 | 4 | |-------------------------------------------------------------------------------------------------------------|----------------|----------------------------|
|
| 5 | +| [4.8.0](#480-2024-09-21) | September 2024 | `14.4 KB` | |
5 | 6 | | [4.7.5](#475-2024-03-14) | March 2024 | `14.6 KB` |
|
6 | 7 | | [4.7.4](#474-2024-01-12) | January 2024 | `14.5 KB` |
|
7 | 8 | | [4.7.3](#473-2024-01-03) | January 2024 | `14.5 KB` |
|
|
50 | 51 |
|
51 | 52 | # Release notes
|
52 | 53 |
|
| 54 | +# [4.8.0](https://github.com/socketio/socket.io/compare/socket.io-client@4.7.5...socket.io-client@4.8.0) (2024-09-21) |
| 55 | + |
| 56 | +### Features |
| 57 | + |
| 58 | +#### Custom transport implementations |
| 59 | + |
| 60 | +The `transports` option now accepts an array of transport implementations: |
| 61 | + |
| 62 | +```js |
| 63 | +import { io } from "socket.io-client"; |
| 64 | +import { XHR, WebSocket } from "engine.io-client"; |
| 65 | + |
| 66 | +const socket = io({ |
| 67 | + transports: [XHR, WebSocket] |
| 68 | +}); |
| 69 | +``` |
| 70 | + |
| 71 | +Here is the list of provided implementations: |
| 72 | + |
| 73 | +| Transport | Description | |
| 74 | +|-----------------|------------------------------------------------------------------------------------------------------| |
| 75 | +| `Fetch` | HTTP long-polling based on the built-in `fetch()` method. | |
| 76 | +| `NodeXHR` | HTTP long-polling based on the `XMLHttpRequest` object provided by the `xmlhttprequest-ssl` package. | |
| 77 | +| `XHR` | HTTP long-polling based on the built-in `XMLHttpRequest` object. | |
| 78 | +| `NodeWebSocket` | WebSocket transport based on the `WebSocket` object provided by the `ws` package. | |
| 79 | +| `WebSocket` | WebSocket transport based on the built-in `WebSocket` object. | |
| 80 | +| `WebTransport` | WebTransport transport based on the built-in `WebTransport` object. | |
| 81 | + |
| 82 | +Usage: |
| 83 | + |
| 84 | +| Transport | browser | Node.js | Deno | Bun | |
| 85 | +|-----------------|--------------------|------------------------|--------------------|--------------------| |
| 86 | +| `Fetch` | :white_check_mark: | :white_check_mark: (1) | :white_check_mark: | :white_check_mark: | |
| 87 | +| `NodeXHR` | | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
| 88 | +| `XHR` | :white_check_mark: | | | | |
| 89 | +| `NodeWebSocket` | | :white_check_mark: | :white_check_mark: | :white_check_mark: | |
| 90 | +| `WebSocket` | :white_check_mark: | :white_check_mark: (2) | :white_check_mark: | :white_check_mark: | |
| 91 | +| `WebTransport` | :white_check_mark: | :white_check_mark: | | | |
| 92 | + |
| 93 | +(1) since [v18.0.0](https://nodejs.org/api/globals.html#fetch) |
| 94 | +(2) since [v21.0.0](https://nodejs.org/api/globals.html#websocket) |
| 95 | + |
| 96 | +Added in [f4d898e](https://github.com/socketio/engine.io-client/commit/f4d898ee9652939a4550a41ac0e8143056154c0a) and [b11763b](https://github.com/socketio/engine.io-client/commit/b11763beecfe4622867b4dec9d1db77460733ffb). |
| 97 | + |
| 98 | + |
| 99 | +#### Test each low-level transports |
| 100 | + |
| 101 | +When setting the `tryAllTransports` option to `true`, if the first transport (usually, HTTP long-polling) fails, then the other transports will be tested too: |
| 102 | + |
| 103 | +```js |
| 104 | +import { io } from "socket.io-client"; |
| 105 | + |
| 106 | +const socket = io({ |
| 107 | + tryAllTransports: true |
| 108 | +}); |
| 109 | +``` |
| 110 | + |
| 111 | +This feature is useful in two cases: |
| 112 | + |
| 113 | +- when HTTP long-polling is disabled on the server, or if CORS fails |
| 114 | +- when WebSocket is tested first (with `transports: ["websocket", "polling"]`) |
| 115 | + |
| 116 | +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. |
| 117 | + |
| 118 | +Added in [579b243](https://github.com/socketio/engine.io-client/commit/579b243e89ac7dc58233f9844ef70817364ecf52). |
| 119 | + |
| 120 | + |
| 121 | +### Bug Fixes |
| 122 | + |
| 123 | +* accept string | undefined as init argument (bis) ([60c757f](https://github.com/socketio/socket.io/commit/60c757f718d400e052c3160ee377bbe4973277c9)) |
| 124 | +* allow to manually stop the reconnection loop ([13c6d2e](https://github.com/socketio/socket.io/commit/13c6d2e89deb1e6c6c8c7245118f9b37d66537cb)) |
| 125 | +* close the engine upon decoding exception ([04c8dd9](https://github.com/socketio/socket.io/commit/04c8dd979ce40acaceec1f4507c1ae69325d6158)) |
| 126 | +* do not send a packet on an expired connection ([#5134](https://github.com/socketio/socket.io/issues/5134)) ([8adcfbf](https://github.com/socketio/socket.io/commit/8adcfbfde50679095ec2abe376650cf2b6814325)) |
| 127 | + |
| 128 | + |
| 129 | +### Dependencies |
| 130 | + |
| 131 | +- [`engine.io-client@~6.6.1`](https://github.com/socketio/engine.io-client/releases/tag/6.5.2) ([diff](https://github.com/socketio/engine.io-client/compare/6.5.3...6.6.0) and [diff](https://github.com/socketio/socket.io/compare/engine.io-client@6.6.0...engine.io-client@6.6.1)) |
| 132 | +- [`ws@~8.17.1`](https://github.com/websockets/ws/releases/tag/8.17.1) ([diff](https://github.com/websockets/ws/compare/8.11.0...8.17.1)) |
| 133 | + |
| 134 | + |
| 135 | + |
53 | 136 | ## [4.7.5](https://github.com/socketio/socket.io-client/compare/4.7.4...4.7.5) (2024-03-14)
|
54 | 137 |
|
55 | 138 |
|
|
0 commit comments