The ClusterAdapter class has been moved to [1], so that this adapter
only needs to implement to pub/sub mechanism.
Also, [2] should reduce the number of "timeout reached: only x
responses received out of y" errors, since the fetchSockets() requests
will now succeed even if a server leaves the cluster.
[1]: https://github.com/socketio/socket.io/tree/main/packages/socket.io-adapter
[2]: 0e23ff0cc6
The init() method of the adapter will now be called when creating a namespace with `io.of(<the-namespace>)`.
Note: any promise rejection is silently caught, as I don't see how we could properly expose the promise.
```js
const io = new Server({
adapter: myAdapter
});
// under the hood, this:
// - implicitly creates the main namespace (/)
// - creates an instance of `myAdapter` for the main namespace
// - calls `myAdapter.init()` (with this change)
```
Related:
- https://github.com/socketio/socket.io/issues/3662
- https://github.com/socketio/socket.io-postgres-adapter/issues/16
This reverts commit 7427109658.
The new version of the `cookie` package contains code with optional chaining (`?.`), which is not supported by older Node.js versions (< 14).
The types for cookie are now bundled, so that there is no conflict with the types coming from `cookie@1`:
> error TS2724: '"cookie"' has no exported member named 'CookieSerializeOptions'. Did you mean 'SerializeOptions'?
>
> import type { CookieSerializeOptions } from "cookie";
> ~~~~~~~~~~~~~~~~~~~~~~
Related: https://github.com/socketio/socket.io/issues/5283
This should fix the following issue:
```
SyntaxError: Named export 'WebSocket' not found. The requested module 'ws' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'ws';
const { WebSocket } = pkg;
```
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
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