Commit Graph

7562 Commits

Author SHA1 Message Date
Damien Arrachequesne
59838b71a2 docs: move changelog of the socket.io package 2024-07-04 18:59:19 +02:00
Damien Arrachequesne
ae3c26fdd4 docs: restore readme 2024-07-04 18:58:18 +02:00
Damien Arrachequesne
c508501d86 Merge remote-tracking branch 'socket.io-protocol/v3'
Source: https://github.com/socketio/socket.io-protocol/tree/v3
2024-07-04 18:30:39 +02:00
Damien Arrachequesne
bbcad832fa Merge remote-tracking branch 'socket.io-protocol/v4'
Source: https://github.com/socketio/socket.io-protocol/tree/v4
2024-07-04 18:29:51 +02:00
Damien Arrachequesne
f1c8410c3e refactor: prepare the migration to a monorepo 2024-07-04 18:29:15 +02:00
Damien Arrachequesne
93b42f6b77 refactor: prepare the migration to a monorepo 2024-07-04 18:27:57 +02:00
Damien Arrachequesne
dfac908769 Merge remote-tracking branch 'socket.io-protocol/main'
Source: https://github.com/socketio/socket.io-protocol
2024-07-04 18:25:43 +02:00
Damien Arrachequesne
b4002c281f refactor: prepare the migration to a monorepo 2024-07-04 18:23:59 +02:00
Damien Arrachequesne
4cac3724ad chore: update the repository URLs
Reference: https://docs.npmjs.com/cli/v10/configuring-npm/package-json
2024-07-04 18:16:51 +02:00
Damien Arrachequesne
914716d71d ci: move building the examples to its own workflow 2024-07-04 18:08:06 +02:00
Damien Arrachequesne
d9b4c3cb03 ci: create npm workspaces and sort out dependencies
This requires at least npm v7.

Reference: https://docs.npmjs.com/cli/v10/using-npm/workspaces

Note: @types/node is pinned at `18.15.3` because it's the last version
which supports TypeScript v4.2.
2024-07-04 17:48:46 +02:00
Damien Arrachequesne
7aedc79436 Merge remote-tracking branch 'socket.io-parser/main' into monorepo
Source: https://github.com/socketio/socket.io-parser
2024-07-04 17:38:27 +02:00
Damien Arrachequesne
bd02c7234a refactor: prepare the migration to a monorepo 2024-07-04 17:37:35 +02:00
Damien Arrachequesne
b2cf3f72fd Merge remote-tracking branch 'socket.io-client/main' into monorepo
Source: https://github.com/socketio/socket.io-client
2024-07-04 17:36:18 +02:00
Damien Arrachequesne
273093ceae refactor: prepare the migration to a monorepo 2024-07-04 17:35:42 +02:00
Damien Arrachequesne
d9d19b4bb7 refactor: prepare the migration to a monorepo 2024-07-04 17:33:59 +02:00
Damien Arrachequesne
f21de7b00e docs: add note about UTF-8 encoding
Related: https://github.com/socketio/engine.io-protocol/issues/42
2024-07-01 21:54:51 +02:00
Damien Arrachequesne
c815579e1b docs: fix typo
Related: https://github.com/socketio/engine.io-protocol/issues/43
2024-07-01 17:23:19 +02:00
Damien Arrachequesne
88016b808a docs(security): update the list of CVE 2024-06-25 15:48:06 +02:00
Damien Arrachequesne
71eaec477c docs(changelog): improve the changelog for version 6.6.0 2024-06-22 10:20:15 +02:00
Damien Arrachequesne
791aa58f4c chore(release): 6.6.0
Diff: https://github.com/socketio/engine.io/compare/6.5.4...6.6.0
engine.io@6.6.0
2024-06-21 14:32:55 +02:00
Damien Arrachequesne
a17cbc5418 chore(release): 6.6.0
Diff: https://github.com/socketio/engine.io-client/compare/6.5.3...6.6.0
engine.io-client@6.6.0
2024-06-21 14:11:15 +02:00
Damien Arrachequesne
6d8a0bea49 refactor: move the req attribute to the polling class 2024-06-21 14:03:22 +02:00
Damien Arrachequesne
c310b7b6b6 refactor: improve types 2024-06-21 14:03:01 +02:00
Damien Arrachequesne
362bc78191 fix: properly call the send callback during upgrade
The "drain" event (added in [1]) had two different meanings:

- the transport is ready to be written
- the packets are sent over the wire

For the WebSocket and the WebTransport transports, those two events
happen at the same time, but this is not the case for the HTTP
long-polling transport:

- the transport is ready to be written when the client sends a GET request
- the packets are sent over the wire when the server responds to the GET request

Which caused an issue with send callbacks during an upgrade, since the
packets were written but the client would not open a new GET request.

There are now two distinct events: "ready" and "drain"

Related: https://github.com/socketio/engine.io/issues/695

[1]: 2a93f06e27
2024-06-21 11:47:41 +02:00
dependabot[bot]
afd29341ee chore(dev-deps): bump ws and engine.io-client in /examples/memory-usage (#703)
Bumps [ws](https://github.com/websockets/ws) to 8.17.1 and updates ancestor dependency [engine.io-client](https://github.com/socketio/engine.io-client). These dependencies need to be updated together.


Updates `ws` from 8.11.0 to 8.17.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.11.0...8.17.1)

Updates `engine.io-client` from 6.5.3 to 6.5.4
- [Release notes](https://github.com/socketio/engine.io-client/releases)
- [Changelog](https://github.com/socketio/engine.io-client/blob/6.5.4/CHANGELOG.md)
- [Commits](https://github.com/socketio/engine.io-client/compare/6.5.3...6.5.4)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
- dependency-name: engine.io-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 20:18:57 +02:00
dependabot[bot]
56c4664bcf chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#701)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 20:18:35 +02:00
Damien Arrachequesne
6b9e3e458e refactor: improve types 2024-06-18 17:37:12 +02:00
Damien Arrachequesne
f521cbab6d refactor: simplify the heartbeat code 2024-06-18 17:32:06 +02:00
Damien Arrachequesne
5359bae683 perf: do not reset the hearbeat timer on each packet
This behavior was added in [1]. However, there are two problems:

- a new timer is allocated every time a packet is received, which is
wasteful

- the next heartbeat is not actually delayed, since it's the timeout
timer which gets reset, and not the interval timer

Note: delaying the next heartbeat would be a breaking change.

[1]: be7b4e7478
2024-06-18 17:17:17 +02:00
Semih Han Ordu
fb5904ee5f chore(deps): bump ws to version 8.17.1 (#5052)
Includes the following security fix: e55e5106f1

Advisory: https://github.com/advisories/GHSA-3h5v-q93c-6h6q
Diff: https://github.com/websockets/ws/compare/8.11.0...8.17.1
2024-06-18 14:40:30 +02:00
Damien Arrachequesne
05a190a9db chore(release): 6.5.5
Diff: https://github.com/socketio/socket.io-adapter/compare/2.5.4...2.5.5
socket.io-adapter@2.5.5
2024-06-18 12:23:45 +02:00
Andrew Bromwich
93fe19019e chore(deps): bump ws from 8.11.0 to 8.17.1 (#93)
Includes the following security fix: e55e5106f1

Advisory: https://github.com/advisories/GHSA-3h5v-q93c-6h6q
Diff: https://github.com/websockets/ws/compare/8.11.0...8.17.1
2024-06-18 12:21:29 +02:00
Damien Arrachequesne
d3f45dca38 docs(changelog): add release notes for versions 3.6.2 and 6.5.5 2024-06-18 10:47:10 +02:00
Damien Arrachequesne
72408ad462 docs(changelog): include release notes from versions 3.5.3, 3.5.4 and 6.5.4 2024-06-18 10:43:04 +02:00
dependabot[bot]
3c4d314998 chore(deps): bump ws from 8.11.0 to 8.17.1 (#702)
Bumps [ws](https://github.com/websockets/ws) from 8.11.0 to 8.17.1.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.11.0...8.17.1)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 09:57:32 +02:00
dependabot[bot]
e97a4d3b82 chore: bump ws from 8.11.0 to 8.17.1 (#720)
Bumps [ws](https://github.com/websockets/ws) from 8.11.0 to 8.17.1.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.11.0...8.17.1)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 09:54:33 +02:00
Damien Arrachequesne
b0721e6407 ci: upgrade to actions/checkout@4 and actions/setup-node@4
Reference: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-06-17 17:50:39 +02:00
Damien Arrachequesne
9a68c8ce93 perf(websocket): use bound callbacks
Instead of allocating one temporary function for each WebSocket
`send()` call.

Regarding the test removal, the permessage-deflate threshold was
implemented in the "ws" package in [1], so it's not needed anymore.

[1]: 6b3904b42d
2024-06-17 17:47:46 +02:00
Damien Arrachequesne
62f59b6cf3 refactor: remove unnecessary array allocation
If the `packetsFn` array is empty, there is no need to allocate one new
array.
2024-06-14 01:07:48 +02:00
Damien Arrachequesne
407c3ad236 refactor: simplify the handling of the "drain" event
The two event handlers are merged into one.
2024-06-14 00:30:14 +02:00
Damien Arrachequesne
ef1c4c8bb7 refactor: remove the wsPreEncoded option
The wsPreEncoded option was added in the `socket.io-adapter` package
when broadcasting a message to multiple clients.

It was removed in [1] and is now superseded by the `wsPreEncodedFrame`
option, which directly computes the WebSocket frame once for all
clients (see [2]).

[1]: 88eee5948a
[2]: 5f7b47d40f
2024-06-13 23:55:16 +02:00
Damien Arrachequesne
8955eb7b75 docs(examples): add some examples to track the memory usage
Related: fc21c4a05f
2024-06-13 23:21:26 +02:00
Jonathan Perret
fc21c4a05f fix: fix websocket and webtransport send callbacks (#699)
With the `websocket` transport, the callbacks which indicate that the
packets are actually written were not properly called.

Example:

```js
socket.send("hello", () => {
  // the message has been written to the underlying transport
});
```

The bug was caused by the `websocket` transport (and `webtransport` as
well) having its `supportsFraming` property set to `true`, despite
having been changed in [1] to emit a single `drain` event for each
batch of messages written to the transport like the `polling` transport
always did. Note that although [1] is partially reverted in [2], the
new `drain` event behavior is preserved as called out in that commit's
message.

The `supportsFraming` attribute was introduced in [3] (amended by [4])
as a way to distinguish transports that emit one `drain` per message
from those that emit one `drain` per batch. Since the delivery of
`send` callbacks depends on matching `drain` events with
`transport.send` calls, that distinction is vital to correct behavior.

However, now that all transports have converged to "one `drain` per
batch" behavior, this `supportsFraming` property can be retired (and
the code for calling callbacks simplified).

[1]: https://github.com/socketio/engine.io/pull/618
[2]: a65a047526
[3]: https://github.com/socketio/engine.io/pull/130
[4]: https://github.com/socketio/engine.io/pull/132

Related: https://github.com/socketio/engine.io/issues/698
2024-06-13 23:02:22 +02:00
Jakub Szaredko
579d34412a chore: fix compilation on macOS (#1616) 2024-06-11 12:30:57 +02:00
Damien Arrachequesne
b624c50832 fix: add some randomness to the cache busting string generator
The yeast() method could generate the same string twice when used in
two different iframes, which can cause Safari to only send one HTTP
request (deduplication) and trigger an HTTP 400 error afterwards since
the two iframes share the same session ID.

This new method, combining 5 chars from the timestamp and 3 chars from
Math.random() should be sufficient for our use case.

Related: https://github.com/socketio/engine.io/issues/690

See also: 874484cc1e
2024-06-05 13:44:55 +02:00
Damien Arrachequesne
c087dc5f32 docs(changelog): include the size of the bundle 2024-06-04 17:19:31 +02:00
Damien Arrachequesne
ce13763b52 ci: upgrade to actions/checkout@4 and actions/setup-node@4
Reference: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-06-04 17:08:48 +02:00
Damien Arrachequesne
74cfb98f12 refactor: prefix private attributes to allow property mangling
|          | before  | after   |
|----------|---------|---------|
| min      | 27.3 KB | 26.1 KB |
| min+gzip | 8.8 KB  | 8.7 KB  |
| min+br   | 8.0 KB  | 7.8 KB  |

Reference: https://terser.org/docs/options/#mangle-properties-options
2024-06-04 17:06:29 +02:00
Damien Arrachequesne
2b9abbbfae chore: 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 6.0.0.

[1]: 27de300de4

See also: 4683a954d4
2024-06-03 14:54:49 +02:00