-
-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Revert "fix: redis pub/sub and streaming response issue" #6083
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 |
|---|---|---|
|
|
@@ -33,7 +33,6 @@ const createInternalPrediction = async (req: Request, res: Response, next: NextF | |
| const createAndStreamInternalPrediction = async (req: Request, res: Response, next: NextFunction) => { | ||
| const chatId = req.body.chatId | ||
| const sseStreamer = getRunningExpressApp().sseStreamer | ||
| const isQueueMode = process.env.MODE === MODE.QUEUE | ||
|
|
||
| try { | ||
| sseStreamer.addClient(chatId, res) | ||
|
|
@@ -43,8 +42,8 @@ const createAndStreamInternalPrediction = async (req: Request, res: Response, ne | |
| 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 utilBuildChatflow(req, true) | ||
|
|
@@ -55,9 +54,6 @@ const createAndStreamInternalPrediction = async (req: Request, res: Response, ne | |
| } | ||
| next(error) | ||
| } finally { | ||
| if (isQueueMode && chatId) { | ||
| await getRunningExpressApp().redisSubscriber.unsubscribe(chatId) | ||
| } | ||
| sseStreamer.removeClient(chatId) | ||
|
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. This revert removes the call to |
||
| } | ||
| } | ||
|
|
||
| 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) | ||
|
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 |
||
| } | ||
|
|
||
| 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) | ||
|
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. This revert removes the call to |
||
| } | ||
| } 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
subscribemethod on the redis client is asynchronous. By removingawait, this operation becomes fire-and-forget. While this might be intended to not block the request, any potential errors during the subscription process will not be caught and will result in an unhandled promise rejection, which could crash the application.