fix(websockets): don't re-throw an error in case of heartbeat error
MODIFY
packages/websockets/src/server/specs/websocket.server.helper.spec.ts
packages/websockets/src/server/specs/websocket.server.helper.spec.ts
@@ -94,9 +94,8 @@ describe('#handleClientBrokenConnection', () => {
// then
scheduler.run(({ expectObservable, flush }) => {
expectObservable(brokenConnection$).toBe(
- `100ms a ${HEART_BEAT_TERMINATE_INTERVAL - 1}ms #`,
- { a: isAlive },
- expect.objectContaining({ name: 'TimeoutError' }),
+ `100ms a ${HEART_BEAT_TERMINATE_INTERVAL - 1}ms (b|)`,
+ { a: isAlive, b: expect.objectContaining({ name: 'TimeoutError' }) },
);
flush();
expect(client.terminate).toHaveBeenCalled();

MODIFY
packages/websockets/src/server/websocket.server.helper.ts
packages/websockets/src/server/websocket.server.helper.ts
import * as WebSocket from 'ws';
-import { EMPTY, fromEvent, merge, SchedulerLike, throwError, interval, from, iif, of } from 'rxjs';
+import { EMPTY, fromEvent, merge, SchedulerLike, interval, from, iif, of } from 'rxjs';
import { takeUntil, catchError, tap, mapTo, timeout, map, mergeMap, mergeMapTo } from 'rxjs/operators';
import { Context, lookup } from '@marblejs/core';
import { WebSocketStatus, WebSocketConnectionLiveness } from '../websocket.interface';
@@ -54,7 +54,7 @@ export const handleClientBrokenConnection = (client: WebSocketClientConnection,
map(client => client.isAlive),
catchError(error => {
client.terminate();
- return throwError(() => error);
+ return of(error);
}),
);

fix(websockets): don't re-throw an error in case of heartbeat error