From e0c2d095b3fbbb9ece0f33ec91135e4abf1211cf Mon Sep 17 00:00:00 2001 From: Alexander Zinin Date: Tue, 8 Oct 2024 15:28:13 +0400 Subject: [PATCH] fix socketTimeout connection instability --- lib/DataHandler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/DataHandler.ts b/lib/DataHandler.ts index 717de6de..23921590 100644 --- a/lib/DataHandler.ts +++ b/lib/DataHandler.ts @@ -56,9 +56,13 @@ export default class DataHandler { }, }); - redis.stream.on("data", (data) => { + redis.stream.prependListener("data", (data) => { parser.execute(data); }); + + // `prependListener` not switching a stream to flowing mode as `on` does, + // so we need to do it manually in case if our listener is the first one + redis.stream.resume(); } private returnFatalError(err: Error) {