-
-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Revert "fix: redis pub/sub and streaming response issue" #6084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,6 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction) | |
| chatId = req.body.chatId ?? req.body.overrideConfig?.sessionId ?? uuidv4() | ||
| req.body.chatId = chatId | ||
| } | ||
| const isQueueMode = process.env.MODE === MODE.QUEUE | ||
| try { | ||
| sseStreamer.addExternalClient(chatId, res) | ||
| res.setHeader('Content-Type', 'text/event-stream') | ||
|
|
@@ -73,8 +72,8 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction) | |
| res.setHeader('X-Accel-Buffering', 'no') //nginx config: https://serverfault.com/a/801629 | ||
| res.flushHeaders() | ||
|
|
||
| if (isQueueMode) { | ||
| await getRunningExpressApp().redisSubscriber.subscribe(chatId) | ||
| if (process.env.MODE === MODE.QUEUE) { | ||
| getRunningExpressApp().redisSubscriber.subscribe(chatId) | ||
| } | ||
|
|
||
| const apiResponse = await predictionsServices.buildChatflow(req) | ||
|
|
@@ -85,9 +84,6 @@ const createPrediction = async (req: Request, res: Response, next: NextFunction) | |
| } | ||
| next(error) | ||
| } finally { | ||
| if (isQueueMode && chatId) { | ||
| await getRunningExpressApp().redisSubscriber.unsubscribe(chatId) | ||
| } | ||
| sseStreamer.removeClient(chatId) | ||
| } | ||
|
Comment on lines
86
to
88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic to unsubscribe from the Redis channel in the |
||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic to unsubscribe from the Redis channel in the
finallyblock has been removed. This will lead to stale subscriptions on the Redis server, as the application subscribes to a channel for each streaming request but never unsubscribes. This is a resource leak that can impact server performance and stability over time. Please reintroduce theunsubscribecall.