@bymax-one/nest-realtime 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -1
- package/README.md +3 -1
- package/dist/internal/index.cjs +40 -458
- package/dist/internal/index.d.cts +13 -2
- package/dist/internal/index.d.ts +13 -2
- package/dist/internal/index.mjs +40 -458
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.d.cts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.mjs +0 -2
- package/dist/shared/index.d.cts +2 -1
- package/dist/shared/index.d.ts +2 -1
- package/dist/websocket/index.cjs +0 -275
- package/dist/websocket/index.mjs +0 -275
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.8] - 2026-11-06
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Built with tsup 9; the shipped bundles no longer carry comments.** The build now strips the
|
|
15
|
+
comments from `dist/**/index.mjs` and `dist/**/index.cjs` after bundling, keeping legal comments,
|
|
16
|
+
`__PURE__` annotations and region markers, and checks that the program is unchanged. The
|
|
17
|
+
declarations keep their comments. The public surface is the same. The `internal` bundle is
|
|
18
|
+
12,293 B brotli, inside its 13,500 B budget; the other budgets were reset to the stripped size
|
|
19
|
+
plus about 11%.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **A host Redis client built with `enableOfflineQueue: false` no longer fails the boot of `RedisRealtimePubSub`.**
|
|
24
|
+
The subscriber connection is a copy of the host client and inherited that option, so its first
|
|
25
|
+
`SUBSCRIBE`, issued before the connection exists, was refused by ioredis at once with
|
|
26
|
+
`Stream isn't writeable and enableOfflineQueue options is false`. Since 1.2.7 that rejection was
|
|
27
|
+
treated as the server refusing the subscription and failed the boot with
|
|
28
|
+
`REALTIME_PUBSUB_UNAVAILABLE`, while Redis was healthy; before 1.2.7 the same combination logged a
|
|
29
|
+
warning and left the instance without cross-instance delivery. The subscriber connection now keeps its own offline queue on, and only an error
|
|
30
|
+
reply from the server counts as a refusal: any other rejection of the first `SUBSCRIBE` is the
|
|
31
|
+
connection failing, so the boot completes unready and recovers like any outage.
|
|
32
|
+
- **`disconnect()` no longer hangs through a Redis outage.** `RedisRealtimePubSub.publish` handed
|
|
33
|
+
the command to ioredis even while the client was reconnecting, and ioredis queued it until the
|
|
34
|
+
connection returned (still pending after 30 s with its default options), so a revocation, and
|
|
35
|
+
every emit, waited out the whole outage and was then sent late. It now rejects at once with
|
|
36
|
+
`REALTIME_PUBSUB_UNAVAILABLE` (`cannot publish to "<channel>" (the Redis client is reconnecting)`)
|
|
37
|
+
while the client is reconnecting, closed or ended, and never queues the command. `disconnect()`
|
|
38
|
+
rejects with that code so the caller can retry, and an emit no longer waits for the outage.
|
|
39
|
+
- **An `sse.heartbeatMs` outside the allowed range now stops the application at start-up.** The
|
|
40
|
+
boot check only rejected a value of zero or less, while the heartbeat service refuses anything
|
|
41
|
+
outside 5,000 to 90,000 ms each time a connection opens. A value such as `1000` or `100000`
|
|
42
|
+
therefore started the application and then answered every SSE connection with a 500.
|
|
43
|
+
`NaN`, which comes from `Number(process.env.HEARTBEAT_MS)` when the variable is unset, passed
|
|
44
|
+
both checks and made the keepalive timer fire about every millisecond on every connection.
|
|
45
|
+
`validateOptions` now applies the same range, for `forRoot` and `forRootAsync`, and the error
|
|
46
|
+
names it: `options.sse.heartbeatMs must be between 5000 and 90000 ms (got 1000)`.
|
|
47
|
+
|
|
48
|
+
#### Apply to a derived backend
|
|
49
|
+
|
|
50
|
+
A `disconnect()` made during a Redis outage now rejects immediately instead of waiting for the
|
|
51
|
+
reconnect, so the retry you already need for a rejected `disconnect()` happens sooner. An emit made
|
|
52
|
+
during an outage is no longer held and delivered late.
|
|
53
|
+
|
|
54
|
+
If your configuration sets `sse.heartbeatMs`, check it is between 5,000 and 90,000 ms. A value
|
|
55
|
+
outside it already failed every connection, except `NaN`, which flooded each connection with
|
|
56
|
+
keepalives; now every one of them fails when the application starts.
|
|
57
|
+
|
|
58
|
+
If you pass `RedisRealtimePubSub` a client created with `enableOfflineQueue: false`,
|
|
59
|
+
upgrade to this release. 1.2.7 fails the boot with `REALTIME_PUBSUB_UNAVAILABLE`
|
|
60
|
+
on such a client. Earlier versions did not fail: they logged `Failed to subscribe to pub/sub ...
|
|
61
|
+
Cross-instance fan-out disabled` once at start-up and then ran without cross-instance delivery, so
|
|
62
|
+
if you ran one of them with such a client, revocations and emits from your other instances may
|
|
63
|
+
never have reached it. Nothing needs to change in your configuration.
|
|
64
|
+
|
|
10
65
|
## [1.2.7] - 2026-11-01
|
|
11
66
|
|
|
12
67
|
### Fixed
|
|
@@ -766,7 +821,8 @@ First published release.
|
|
|
766
821
|
rather than by the manual sweep that raised the NestJS floors — that sweep
|
|
767
822
|
asked about NestJS and never put the same question to the other ten peers.
|
|
768
823
|
|
|
769
|
-
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.2.
|
|
824
|
+
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.2.8...HEAD
|
|
825
|
+
[1.2.8]: https://github.com/bymaxone/nest-realtime/compare/v1.2.7...v1.2.8
|
|
770
826
|
[1.2.7]: https://github.com/bymaxone/nest-realtime/compare/v1.2.6...v1.2.7
|
|
771
827
|
[1.2.6]: https://github.com/bymaxone/nest-realtime/compare/v1.2.5...v1.2.6
|
|
772
828
|
[1.2.5]: https://github.com/bymaxone/nest-realtime/compare/v1.2.4...v1.2.5
|
package/README.md
CHANGED
|
@@ -363,6 +363,8 @@ All options are passed to `forRoot()` / `forRootAsync()`. Only `transport` and `
|
|
|
363
363
|
| **websocket** | `namespace`, `cors`, `maxHttpBufferSize`, `pingIntervalMs`, `pingTimeoutMs`, `maxConnectionsPerUser`, `emitConnectionEvent`, `redisAdapter` | `'/'`, — (Socket.IO defaults) |
|
|
364
364
|
| **reauthenticationPolicy** | `intervalSeconds`, `onFailure` (`'disconnect'` \| `'event'`), `cacheTtlMs` | `300`, `'disconnect'`, `60000` |
|
|
365
365
|
|
|
366
|
+
`sse.heartbeatMs` must be between 5,000 and 90,000 ms. Any other value, including `NaN` and a non-number, stops the application at start-up with `REALTIME_INVALID_OPTIONS`.
|
|
367
|
+
|
|
366
368
|
> [!NOTE]
|
|
367
369
|
> `websocket.maxConnectionsPerUser` is **opt-in** and unlimited unless set to a positive number, while `sse.maxConnectionsPerUser` defaults to `5`. The two transports differ here on purpose: an SSE stream holds an HTTP connection open, a Socket.IO client multiplexes.
|
|
368
370
|
|
|
@@ -572,7 +574,7 @@ The unified emit API. Identical on every transport.
|
|
|
572
574
|
|
|
573
575
|
All methods return `Promise<void>`.
|
|
574
576
|
|
|
575
|
-
**Revocation is never best-effort.** `disconnect(connectionId)` resolves when the connection was closed on this instance or when the revocation was handed to the bus (`IRealtimePubSub`). It **rejects** when it could not: `REALTIME_PUBSUB_UNAVAILABLE` when the bus refuses the publish, `REALTIME_TRANSPORT_UNAVAILABLE` when the WebSocket server is not attached or its fan-out throws. A rejection means the connection may still be connected, so retry. An emit is different: `emitToUser`, `emitToTenant`, `emitToRoom` and `broadcast` stay at-most-once, and **resolve even when the publish to the other instances failed**. That failure is not silent: it is logged with `REALTIME_PUBSUB_UNAVAILABLE` and the operation, and passed to the `onDeliveryFailure` hook, which is where to count it. `emitToUser` also resolves, reporting it the same way, when the offline queue could not keep an event for a user who is offline here, because another instance may have delivered it live. It rejects only when the event has no delivery path left: the user is offline here, the queue failed, and the bus failed or cannot reach another instance (the default in-memory bus).
|
|
577
|
+
**Revocation is never best-effort.** `disconnect(connectionId)` resolves when the connection was closed on this instance or when the revocation was handed to the bus (`IRealtimePubSub`). It **rejects** when it could not: `REALTIME_PUBSUB_UNAVAILABLE` when the bus refuses the publish (`RedisRealtimePubSub` refuses it at once while its client is reconnecting, and does not wait for the connection to return), `REALTIME_TRANSPORT_UNAVAILABLE` when the WebSocket server is not attached or its fan-out throws. A rejection means the connection may still be connected, so retry. An emit is different: `emitToUser`, `emitToTenant`, `emitToRoom` and `broadcast` stay at-most-once, and **resolve even when the publish to the other instances failed**. That failure is not silent: it is logged with `REALTIME_PUBSUB_UNAVAILABLE` and the operation, and passed to the `onDeliveryFailure` hook, which is where to count it. `emitToUser` also resolves, reporting it the same way, when the offline queue could not keep an event for a user who is offline here, because another instance may have delivered it live. It rejects only when the event has no delivery path left: the user is offline here, the queue failed, and the bus failed or cannot reach another instance (the default in-memory bus).
|
|
576
578
|
|
|
577
579
|
`joinRoom` and `leaveRoom` act on a connection **this instance holds**; for any other id they resolve and change nothing. A failure of the transport that holds the connection rejects the call.
|
|
578
580
|
|