@bymax-one/nest-realtime 1.2.10 → 1.2.11
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 +20 -1
- package/README.md +13 -13
- package/dist/internal/index.cjs +3 -0
- package/dist/internal/index.d.cts +7 -0
- package/dist/internal/index.d.ts +7 -0
- package/dist/internal/index.mjs +3 -0
- package/dist/websocket/index.cjs +3 -0
- package/dist/websocket/index.d.cts +11 -1
- package/dist/websocket/index.d.ts +11 -1
- package/dist/websocket/index.mjs +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.11] - 2026-11-09
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **Refusal during shutdown begins at `onModuleDestroy`, not at `beforeApplicationShutdown`.** Nest
|
|
15
|
+
runs the hooks of a module nearer the root before those of a module it imports, so a host's slow
|
|
16
|
+
`beforeApplicationShutdown` in the root module ran before the transport's own, and a WebSocket
|
|
17
|
+
handshake or an SSE stream arriving in that window was accepted. Nest runs every module's
|
|
18
|
+
`onModuleDestroy` before any `beforeApplicationShutdown`, so both transports now mark shutdown as
|
|
19
|
+
begun there: from then on a handshake gets `REALTIME_TRANSPORT_UNAVAILABLE` and a stream gets a 503. A slow `onModuleDestroy` in a module nearer the root than the realtime module still runs
|
|
20
|
+
first, and until it returns a connection is accepted: put slow shutdown work in
|
|
21
|
+
`beforeApplicationShutdown`, or make the host stop accepting traffic before it calls `close()`.
|
|
22
|
+
|
|
23
|
+
#### Apply to a derived backend
|
|
24
|
+
|
|
25
|
+
`SseTransport` and `WebSocketTransport` gain a public `onModuleDestroy()` that marks shutdown as
|
|
26
|
+
begun. A subclass that overrides it has to call `super.onModuleDestroy()`.
|
|
27
|
+
|
|
10
28
|
## [1.2.10] - 2026-11-09
|
|
11
29
|
|
|
12
30
|
### Fixed
|
|
@@ -937,7 +955,8 @@ First published release.
|
|
|
937
955
|
rather than by the manual sweep that raised the NestJS floors — that sweep
|
|
938
956
|
asked about NestJS and never put the same question to the other ten peers.
|
|
939
957
|
|
|
940
|
-
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.2.
|
|
958
|
+
[Unreleased]: https://github.com/bymaxone/nest-realtime/compare/v1.2.11...HEAD
|
|
959
|
+
[1.2.11]: https://github.com/bymaxone/nest-realtime/compare/v1.2.10...v1.2.11
|
|
941
960
|
[1.2.10]: https://github.com/bymaxone/nest-realtime/compare/v1.2.9...v1.2.10
|
|
942
961
|
[1.2.9]: https://github.com/bymaxone/nest-realtime/compare/v1.2.8...v1.2.9
|
|
943
962
|
[1.2.8]: https://github.com/bymaxone/nest-realtime/compare/v1.2.7...v1.2.8
|
package/README.md
CHANGED
|
@@ -871,19 +871,19 @@ These names belong to the library. Do not reuse them for application events. The
|
|
|
871
871
|
|
|
872
872
|
### Error Codes
|
|
873
873
|
|
|
874
|
-
| Code | Status
|
|
875
|
-
| ---------------------------------- |
|
|
876
|
-
| `REALTIME_INVALID_OPTIONS` | Raised at bootstrap for an invalid option
|
|
877
|
-
| `REALTIME_NO_AUTHENTICATOR` | Raised at bootstrap when the authenticator is missing or invalid
|
|
878
|
-
| `REALTIME_AUTH_FAILED` | Raised when authentication is refused: the SSE 401 body and the WebSocket handshake refusal
|
|
879
|
-
| `REALTIME_REAUTHENTICATION_FAILED` | Raised when a revalidation fails
|
|
880
|
-
| `REALTIME_TOO_MANY_CONNECTIONS` | Raised as the reason an evicted connection is closed
|
|
881
|
-
| `REALTIME_INVALID_TICKET` | Reserved, never raised today: a ticket store is yours to write
|
|
882
|
-
| `REALTIME_PUBSUB_UNAVAILABLE` | Raised as the rejection of a disconnect when the bus refuses the revocation; an emit's publish failure is logged and passed to the delivery-failure hook
|
|
883
|
-
| `REALTIME_TRANSPORT_UNAVAILABLE` | Raised as the rejection of a disconnect, a join or a leave when the transport that holds the connection fails or has no server attached, and of an emit to an offline user that has no delivery path left. Also what a new SSE stream or WebSocket handshake is refused with once shutdown has begun: a 503 whose message is the code, and a connect_error whose data.code is the code |
|
|
884
|
-
| `REALTIME_REDIS_ADAPTER_FAILED` | Raised at bootstrap when the Redis adapter is configured and cannot be installed
|
|
885
|
-
| `REALTIME_PAYLOAD_TOO_LARGE` | Reserved, never raised today
|
|
886
|
-
| `REALTIME_REPLAY_BUFFER_MISS` | Reserved, never raised today
|
|
874
|
+
| Code | Status |
|
|
875
|
+
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
876
|
+
| `REALTIME_INVALID_OPTIONS` | Raised at bootstrap for an invalid option |
|
|
877
|
+
| `REALTIME_NO_AUTHENTICATOR` | Raised at bootstrap when the authenticator is missing or invalid |
|
|
878
|
+
| `REALTIME_AUTH_FAILED` | Raised when authentication is refused: the SSE 401 body and the WebSocket handshake refusal |
|
|
879
|
+
| `REALTIME_REAUTHENTICATION_FAILED` | Raised when a revalidation fails |
|
|
880
|
+
| `REALTIME_TOO_MANY_CONNECTIONS` | Raised as the reason an evicted connection is closed |
|
|
881
|
+
| `REALTIME_INVALID_TICKET` | Reserved, never raised today: a ticket store is yours to write |
|
|
882
|
+
| `REALTIME_PUBSUB_UNAVAILABLE` | Raised as the rejection of a disconnect when the bus refuses the revocation; an emit's publish failure is logged and passed to the delivery-failure hook |
|
|
883
|
+
| `REALTIME_TRANSPORT_UNAVAILABLE` | Raised as the rejection of a disconnect, a join or a leave when the transport that holds the connection fails or has no server attached, and of an emit to an offline user that has no delivery path left. Also what a new SSE stream or WebSocket handshake is refused with once shutdown has begun: a 503 whose message is the code, and a connect_error whose data.code is the code. Shutdown begins, for this purpose, in the onModuleDestroy phase, ahead of every beforeApplicationShutdown hook, so a slow beforeApplicationShutdown in the host does not leave a window; a slow onModuleDestroy in a module nearer the root than the realtime module still runs first, and a connection is accepted until it returns. |
|
|
884
|
+
| `REALTIME_REDIS_ADAPTER_FAILED` | Raised at bootstrap when the Redis adapter is configured and cannot be installed |
|
|
885
|
+
| `REALTIME_PAYLOAD_TOO_LARGE` | Reserved, never raised today |
|
|
886
|
+
| `REALTIME_REPLAY_BUFFER_MISS` | Reserved, never raised today |
|
|
887
887
|
|
|
888
888
|
### DI Tokens
|
|
889
889
|
|
package/dist/internal/index.cjs
CHANGED
|
@@ -551,6 +551,9 @@ exports.SseTransport = class SseTransport {
|
|
|
551
551
|
options;
|
|
552
552
|
instanceId;
|
|
553
553
|
offlineQueue;
|
|
554
|
+
onModuleDestroy() {
|
|
555
|
+
__privateSet(this, _shuttingDown, true);
|
|
556
|
+
}
|
|
554
557
|
async beforeApplicationShutdown() {
|
|
555
558
|
__privateSet(this, _shuttingDown, true);
|
|
556
559
|
this.heartbeat.stopAll();
|
|
@@ -1215,6 +1215,13 @@ declare class SseTransport implements ITransport {
|
|
|
1215
1215
|
readonly kind: "sse";
|
|
1216
1216
|
private readonly logger;
|
|
1217
1217
|
constructor(connections: ConnectionRegistry, rooms: RoomRegistry, replayBuffer: EventReplayBuffer, idGen: EventIdGenerator, heartbeat: HeartbeatService, auth: IConnectionAuthenticator, pubsub: IRealtimePubSub, hooks: IConnectionLifecycleHooks, options: BymaxRealtimeModuleOptions, instanceId: string, offlineQueue?: IOfflineQueueStorage | undefined);
|
|
1218
|
+
/**
|
|
1219
|
+
* Mark shutdown as begun at the first hook Nest runs on close, so that a slow
|
|
1220
|
+
* `beforeApplicationShutdown` of the host's, which Nest runs before this transport's when it is in a
|
|
1221
|
+
* module nearer the root, cannot leave a window in which a new stream is accepted. A slow
|
|
1222
|
+
* `onModuleDestroy` in such a module still runs first; nothing the library owns runs earlier.
|
|
1223
|
+
*/
|
|
1224
|
+
onModuleDestroy(): void;
|
|
1218
1225
|
/**
|
|
1219
1226
|
* Tear down every SSE connection and stop heartbeat before the HTTP server closes.
|
|
1220
1227
|
*
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1215,6 +1215,13 @@ declare class SseTransport implements ITransport {
|
|
|
1215
1215
|
readonly kind: "sse";
|
|
1216
1216
|
private readonly logger;
|
|
1217
1217
|
constructor(connections: ConnectionRegistry, rooms: RoomRegistry, replayBuffer: EventReplayBuffer, idGen: EventIdGenerator, heartbeat: HeartbeatService, auth: IConnectionAuthenticator, pubsub: IRealtimePubSub, hooks: IConnectionLifecycleHooks, options: BymaxRealtimeModuleOptions, instanceId: string, offlineQueue?: IOfflineQueueStorage | undefined);
|
|
1218
|
+
/**
|
|
1219
|
+
* Mark shutdown as begun at the first hook Nest runs on close, so that a slow
|
|
1220
|
+
* `beforeApplicationShutdown` of the host's, which Nest runs before this transport's when it is in a
|
|
1221
|
+
* module nearer the root, cannot leave a window in which a new stream is accepted. A slow
|
|
1222
|
+
* `onModuleDestroy` in such a module still runs first; nothing the library owns runs earlier.
|
|
1223
|
+
*/
|
|
1224
|
+
onModuleDestroy(): void;
|
|
1218
1225
|
/**
|
|
1219
1226
|
* Tear down every SSE connection and stop heartbeat before the HTTP server closes.
|
|
1220
1227
|
*
|
package/dist/internal/index.mjs
CHANGED
|
@@ -549,6 +549,9 @@ var SseTransport = class {
|
|
|
549
549
|
options;
|
|
550
550
|
instanceId;
|
|
551
551
|
offlineQueue;
|
|
552
|
+
onModuleDestroy() {
|
|
553
|
+
__privateSet(this, _shuttingDown, true);
|
|
554
|
+
}
|
|
552
555
|
async beforeApplicationShutdown() {
|
|
553
556
|
__privateSet(this, _shuttingDown, true);
|
|
554
557
|
this.heartbeat.stopAll();
|
package/dist/websocket/index.cjs
CHANGED
|
@@ -85,7 +85,17 @@ declare class WebSocketTransport implements ITransport {
|
|
|
85
85
|
private warnedUnattached;
|
|
86
86
|
constructor(connections: ConnectionRegistry, rooms: RoomRegistry, auth: IConnectionAuthenticator, hooks: IConnectionLifecycleHooks, options: BymaxRealtimeModuleOptions);
|
|
87
87
|
/**
|
|
88
|
-
* Mark shutdown as begun, so
|
|
88
|
+
* Mark shutdown as begun at the first hook Nest runs on close, so that no hook of the host's, however
|
|
89
|
+
* slow, can leave a window in which a handshake is accepted.
|
|
90
|
+
*
|
|
91
|
+
* Nest runs every module's `onModuleDestroy` before any `beforeApplicationShutdown`, and within a
|
|
92
|
+
* phase it runs a module nearer the root before one it imports, so a slow `beforeApplicationShutdown`
|
|
93
|
+
* in the host's root module runs before this transport's own. A slow `onModuleDestroy` in a module
|
|
94
|
+
* nearer the root than the realtime module still runs first; nothing the library owns runs earlier.
|
|
95
|
+
*/
|
|
96
|
+
onModuleDestroy(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Mark shutdown as begun, for a caller that runs only this hook; `onModuleDestroy` already did.
|
|
89
99
|
*
|
|
90
100
|
* Socket.IO closes every connection that is open when the server closes, so no connection is
|
|
91
101
|
* torn down here; a socket accepted after this point would only be closed a moment later, and
|
|
@@ -85,7 +85,17 @@ declare class WebSocketTransport implements ITransport {
|
|
|
85
85
|
private warnedUnattached;
|
|
86
86
|
constructor(connections: ConnectionRegistry, rooms: RoomRegistry, auth: IConnectionAuthenticator, hooks: IConnectionLifecycleHooks, options: BymaxRealtimeModuleOptions);
|
|
87
87
|
/**
|
|
88
|
-
* Mark shutdown as begun, so
|
|
88
|
+
* Mark shutdown as begun at the first hook Nest runs on close, so that no hook of the host's, however
|
|
89
|
+
* slow, can leave a window in which a handshake is accepted.
|
|
90
|
+
*
|
|
91
|
+
* Nest runs every module's `onModuleDestroy` before any `beforeApplicationShutdown`, and within a
|
|
92
|
+
* phase it runs a module nearer the root before one it imports, so a slow `beforeApplicationShutdown`
|
|
93
|
+
* in the host's root module runs before this transport's own. A slow `onModuleDestroy` in a module
|
|
94
|
+
* nearer the root than the realtime module still runs first; nothing the library owns runs earlier.
|
|
95
|
+
*/
|
|
96
|
+
onModuleDestroy(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Mark shutdown as begun, for a caller that runs only this hook; `onModuleDestroy` already did.
|
|
89
99
|
*
|
|
90
100
|
* Socket.IO closes every connection that is open when the server closes, so no connection is
|
|
91
101
|
* torn down here; a socket accepted after this point would only be closed a moment later, and
|
package/dist/websocket/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-realtime",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Realtime backend → frontend communication for NestJS — dual-transport SSE (default) and WebSocket (opt-in) with a unified server-side API.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|