Skip to content

Commit 4326cbe

Browse files
Fix: Patching redis socket crash fix (#4431)
* redis keepalive mechanism for all redis * removed offline queue commands * Simplified changes for consistency. Added REDIS_KEEP_ALIVE env variable. * update redis socket alive env variable * lint fix * put pingInterval back again because it's needed * removed comment * linting --------- Co-authored-by: Henry <hzj94@hotmail.com> Co-authored-by: Henry Heng <henryheng@flowiseai.com>
1 parent 7e7ff24 commit 4326cbe

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

packages/components/nodes/vectorstores/Redis/Redis.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ class Redis_VectorStores implements INode {
153153
keepAlive:
154154
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
155155
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
156-
: undefined // milliseconds
157-
}
156+
: undefined
157+
},
158+
pingInterval:
159+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
160+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
161+
: undefined // Add Redis protocol-level pings
158162
})
159163
await redisClient.connect()
160164

@@ -226,8 +230,12 @@ class Redis_VectorStores implements INode {
226230
keepAlive:
227231
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
228232
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
229-
: undefined // milliseconds
230-
}
233+
: undefined
234+
},
235+
pingInterval:
236+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
237+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
238+
: undefined // Add Redis protocol-level pings
231239
})
232240

233241
const storeConfig: RedisVectorStoreConfig = {

packages/server/src/queue/RedisEventPublisher.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export class RedisEventPublisher implements IServerSideEventStreamer {
1313
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
1414
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
1515
: undefined
16-
}
16+
},
17+
pingInterval:
18+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
19+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
20+
: undefined
1721
})
1822
} else {
1923
this.redisPublisher = createClient({
@@ -30,7 +34,11 @@ export class RedisEventPublisher implements IServerSideEventStreamer {
3034
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
3135
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
3236
: undefined
33-
}
37+
},
38+
pingInterval:
39+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
40+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
41+
: undefined
3442
})
3543
}
3644
}

packages/server/src/queue/RedisEventSubscriber.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export class RedisEventSubscriber {
1515
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
1616
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
1717
: undefined
18-
}
18+
},
19+
pingInterval:
20+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
21+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
22+
: undefined
1923
})
2024
} else {
2125
this.redisSubscriber = createClient({
@@ -32,7 +36,11 @@ export class RedisEventSubscriber {
3236
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
3337
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
3438
: undefined
35-
}
39+
},
40+
pingInterval:
41+
process.env.REDIS_KEEP_ALIVE && !isNaN(parseInt(process.env.REDIS_KEEP_ALIVE, 10))
42+
? parseInt(process.env.REDIS_KEEP_ALIVE, 10)
43+
: undefined
3644
})
3745
}
3846
this.sseStreamer = sseStreamer

0 commit comments

Comments
 (0)