Commit Graph

7605 Commits

Author SHA1 Message Date
Damien Arrachequesne
7427109658 refactor(eio): bump cookie to version 1.0.2
Release notes: https://github.com/jshttp/cookie/releases/tag/v1.0.0

The types are now included in the npm package. The `CookieSerializeOptions` type, which is used in our `ServerOptions` type, has been renamed to `SerializeOptions`, but there are no breaking change.

Related: https://github.com/socketio/socket.io/issues/5231
2024-11-21 08:57:37 +01:00
Damien Arrachequesne
91e1c8b358 chore(release): socket.io@4.8.1
Diff: https://github.com/socketio/socket.io/compare/socket.io@4.8.0...socket.io@4.8.1
socket.io@4.8.1
2024-10-25 08:13:15 +02:00
Damien Arrachequesne
8d5528aa2a chore(release): socket.io-client@4.8.1
Diff: https://github.com/socketio/socket.io/compare/socket.io-client@4.8.0...socket.io-client@4.8.1
socket.io-client@4.8.1
2024-10-25 08:00:26 +02:00
Damien Arrachequesne
71387e5294 refactor(sio-client): reexport transports from the engine 2024-10-25 07:54:35 +02:00
Samuel Vogelsanger
aead83560d refactor(sio): make Namespace._fns private (#5196)
Related: https://github.com/socketio/socket.io/issues/5179
2024-10-23 10:59:23 +02:00
Damien Arrachequesne
029e010901 chore(release): engine.io-client@6.6.2
Diff: https://github.com/socketio/socket.io/compare/engine.io-client@6.6.1...engine.io-client@6.6.2
engine.io-client@6.6.2
2024-10-23 10:48:16 +02:00
Damien Arrachequesne
4ca6ddb3a2 docs(nuxt): update example with latest version
Related: https://github.com/socketio/socket.io/issues/5208

[skip ci]
2024-10-23 08:19:48 +02:00
Damien Arrachequesne
ca9e994815 fix(sio-client): do not mangle the "_placeholder" attribute
The "_placeholder" attribute is used when sending binary data, and was
incorrectly mangled (converted to a random short property, like "it",
to reduce the bundle size).

This bug was introduced in [1], included in `socket.io-client@4.8.0`.

[1]: 7085f0e3e4

Related: https://github.com/socketio/socket.io/issues/5215
2024-10-22 11:41:08 +02:00
Damien Arrachequesne
4865f2e62e fix(eio-client): prevent infinite loop with Node.js built-in WebSocket
Related: https://github.com/socketio/socket.io/issues/5194
2024-10-22 00:49:25 +02:00
Damien Arrachequesne
d4b3ddedff ci: use Node.js 22
Reference: https://github.com/nodejs/Release
2024-10-21 23:30:11 +02:00
Damien Arrachequesne
3b68658201 chore: bump @fails-components/webtransport to version 1.1.4 (dev) 2024-10-21 23:29:29 +02:00
Damien Arrachequesne
175a2c58c1 fix(eio-client/types): remove ws type from .d.ts file
Before this change, the following error would be thrown when compiling
with TypeScript:

```
node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts:12:101 - error TS1340: Module 'ws' does not refer to a type, but is used as a type here. Did you mean 'typeof import('ws')'?

12     createSocket(uri: string, protocols: string | string[] | undefined, opts: Record<string, any>): import("ws");
                                                                                                       ~~~~~~~~~~~~
```

This behavior was introduced in [1], included in version `6.6.0`.

The return type is forced as `any`, so that the `@types/ws` dependency
is optional.

[1]: f4d898ee96

Related: https://github.com/socketio/socket.io/issues/5202
2024-10-19 07:09:19 +02:00
Damien Arrachequesne
9b80ab42d6 chore(release): engine.io@6.6.2
Diff: https://github.com/socketio/socket.io/compare/engine.io@6.6.1...engine.io@6.6.2
engine.io@6.6.2
2024-10-09 19:01:17 +02:00
Damien Arrachequesne
a5d2368512 ci: ignore tests when publishing to npm (bis)
`tags-ignore` seems to disable the workflow in all cases.
2024-10-09 18:56:59 +02:00
k725
88efd446f1 chore(deps): bump cookie to version 0.7.2 (#5205)
Related: https://github.com/advisories/GHSA-pxg6-pf52-xh8x
2024-10-09 17:47:42 +02:00
Damien Arrachequesne
d0fc720420 chore(release): socket.io@4.8.0
Diff: https://github.com/socketio/socket.io/compare/socket.io@4.7.5...socket.io@4.8.0
socket.io@4.8.0
2024-09-21 10:02:24 +02:00
Damien Arrachequesne
4a0555c671 chore(release): socket.io-client@4.8.0
Diff: https://github.com/socketio/socket.io/compare/socket.io-client@4.7.5...socket.io-client@4.8.0
socket.io-client@4.8.0
2024-09-21 09:45:51 +02:00
Damien Arrachequesne
2b60df18a8 chore(release): engine.io@6.6.1
Diff: https://github.com/socketio/socket.io/compare/engine.io@6.6.0...engine.io@6.6.1
engine.io@6.6.1
2024-09-21 09:30:07 +02:00
Damien Arrachequesne
d4cb375856 ci: ignore tests when publishing to npm 2024-09-21 09:27:42 +02:00
Damien Arrachequesne
c251ae7ba7 chore(release): engine.io-client@6.6.1
Diff: https://github.com/socketio/socket.io/compare/engine.io-client@6.6.0...engine.io-client@6.6.1
engine.io-client@6.6.1
2024-09-21 09:07:48 +02:00
Damien Arrachequesne
8a2f5a3da0 fix(eio-client): move 'offline' event listener at the top
Related: https://github.com/socketio/socket.io/issues/5125
2024-09-21 08:47:20 +02:00
Damien Arrachequesne
b04fa64365 fix(sio): allow to join a room in a middleware (uws)
Related:

- https://github.com/socketio/socket.io/issues/4810
- https://github.com/socketio/socket.io/issues/5139
2024-09-21 08:19:32 +02:00
Damien Arrachequesne
7085f0e3e4 refactor(sio-client): mangle private attributes
|          | before  | after   |
|----------|---------|---------|
| min+gzip | 14.6 KB | 14.3 KB |
| min+br   | 13.1 KB | 12.9 KB |

Reference: https://terser.org/docs/options/#mangle-properties-options
2024-09-21 07:48:50 +02:00
Damien Arrachequesne
4f66708210 chore(sio-client): use babel loose mode when transpiling classes
By default, Babel uses `Object.defineProperty()` when transpiling
classes. We'll now use the loose mode which creates a more terse
output.

|          | before  | after   |
|----------|---------|---------|
| min+gzip | 14.9 KB | 14.6 KB |
| min+br   | 13.4 KB | 13.1 KB |

Reference: https://babeljs.io/docs/babel-plugin-transform-classes
2024-09-21 07:44:15 +02:00
Damien Arrachequesne
1a95db2145 chore(sio-client): add a script to compute the bundle size 2024-09-21 07:34:49 +02:00
Damien Arrachequesne
282ae922a4 chore(sio-client): restore the debug package in the dev bundle
The debug package was not included anymore in the dev bundle since the
migration from webpack to rollup ([1]) in version 4.3.0.

[1]: 0661564dc2

Related: https://github.com/socketio/socket.io/issues/5108
2024-09-21 07:33:53 +02:00
Damien Arrachequesne
93010ca3c4 chore(eio-client): bump xmlhttprequest-ssl to version 2.1.1
Related:

- https://github.com/socketio/socket.io/issues/4402
- b01f69a689
2024-09-21 07:32:12 +02:00
Damien Arrachequesne
132d05fc0b fix(sio): expose type of default engine
Related: https://github.com/socketio/socket.io/issues/4693
2024-09-20 11:18:23 +02:00
Damien Arrachequesne
d5095fe98c fix(eio): prevent the client from upgrading twice (uws)
Related: https://github.com/socketio/socket.io/issues/5066
2024-09-19 12:13:42 +02:00
Damien Arrachequesne
da613810fd test(eio): bump uWebSockets.js to version 20.48.0 2024-09-19 12:12:58 +02:00
Damien Arrachequesne
19c48a44e6 refactor(sio): break circular dependency in source code
Related: https://github.com/socketio/socket.io/issues/4329
2024-09-19 09:27:12 +02:00
Damien Arrachequesne
9b3c9abeca fix(eio-client): only remove the event listener if it exists
Related: https://github.com/socketio/socket.io/issues/5088#issuecomment-2217202350
2024-09-19 09:26:26 +02:00
Damien Arrachequesne
043b55c418 refactor(sio): simplify middleware execution (bis) 2024-09-18 22:15:32 +02:00
Damien Arrachequesne
32c761f02f refactor(sio): export the ExtendedError type
Related: https://github.com/socketio/socket.io/issues/4798
2024-09-18 18:22:06 +02:00
Damien Arrachequesne
1f54ee08c6 refactor(sio): simplify middleware execution 2024-09-18 18:21:58 +02:00
Damien Arrachequesne
923a12e2de fix(eio): discard all pending packets when the server is closed
In some specific cases, the transport was not closed right away,
leaving the Node.js process alive even after closing the server.
The HTTP long-polling transport would be closed after the heartbeat
failure and the `closeTimeout` delay (20 + 25 + 30 seconds).

Example:

```js
io.on("connection", (socket) => {
  // the writeBuffer is not empty, so the transport is not closed right away
  io.close();
});
```

Related: https://github.com/socketio/socket.io/issues/5088
2024-09-18 18:17:14 +02:00
Damien Arrachequesne
13c6d2e89d fix(sio-client): allow to manually stop the reconnection loop
```js
socket.io.on("reconnect_attempt", () => {
  socket.io.reconnection(false); // will now work properly
});
```

Related: https://github.com/socketio/socket.io/issues/5126
2024-09-18 11:19:28 +02:00
Tom Jenkinson
8adcfbfde5 fix(sio-client): do not send a packet on an expired connection (#5134)
When a laptop is suspended or a phone is locked, the timer that is used
to check the liveness of the connection is paused and is not able to
detect that the heartbeat has failed.

Previously, emitting a message after resuming the page would lose the
message. The status of the timer will now be checked before sending the
message, so that it gets buffered and sent upon reconnection.

Note: we could also have used the Page Visibility API or a custom
setTimeout() method based on setInterval(), but this would not be as
reliable as the current solution.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

Related: https://github.com/socketio/socket.io/issues/5135
2024-09-18 11:11:22 +02:00
Damien Arrachequesne
7a23dde6ef perf: do not reset the hearbeat timer on each packet
This reverts ed34a45a07

See also: 5359bae683
2024-09-18 11:06:39 +02:00
Damien Arrachequesne
60c757f718 fix(sio-client): accept string | undefined as init argument (bis)
Following: 5a3eafed1c

Related: https://github.com/socketio/socket.io/issues/4873
2024-09-18 08:09:47 +02:00
Damien Arrachequesne
04c8dd979c fix(sio-client): close the engine upon decoding exception
Related: https://github.com/socketio/socket.io/issues/5128
2024-09-18 07:52:37 +02:00
Damien Arrachequesne
2194264820 test(eio-client): reduce test suite duration 2024-09-18 07:52:12 +02:00
Damien Arrachequesne
09f573cad8 test(sio-client): reduce test suite duration 2024-09-18 07:52:12 +02:00
Damien Arrachequesne
fcbecd4f46 ci: restore package-specific tests 2024-09-17 15:07:23 +02:00
Damien Arrachequesne
fd99f2e15f refactor(sio): export the DefaultEventsMap type
Related: https://github.com/socketio/socket.io/issues/4747
2024-09-16 15:49:15 +02:00
Damien Arrachequesne
02d59a0e99 chore: re-enable publish workflow
This reverts commit 7160eb7eb0.

[skip ci]
2024-09-16 09:11:35 +02:00
Damien Arrachequesne
7160eb7eb0 chore: temporarily disable publish workflow
In order to import tags from other repositories.

[skip ci]
2024-09-16 08:56:07 +02:00
Wang Guan
a1ccba3a77 chore: use prettier v3 everywhere (#5169) 2024-09-16 08:43:08 +02:00
Mark Nelissen
e347a3c24e fix(sio): correctly await async close on adapters (#4971)
Following: bf64870957
2024-09-14 08:51:08 +02:00
nayounsang
b5ccfd4838 refactor(eio-client): improve transports type (#5188)
Related: https://github.com/socketio/socket.io/issues/5187
2024-09-14 08:17:36 +02:00