🐛 fix: Prevent Node Server Crash Due to Unhandled ChatCompletionMessage Error #1278
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I have implemented a temporary workaround to address a bug in the
openai
Node library where the server crashes due to an unhandledChatCompletionMessage
error when working with reverse proxies or APIs mimicking the OpenAI spec. This bug fix ensures that the server remains stable until theopenai
library resolves the underlying issue.Closes #1270
FYI I seem to have issues with ollama independent of LibreChat when I don't include --drop_params, related issue: BerriAI/litellm#992 (comment)
With this change I am also prevent title generation if a request was cancelled.
Relevant
openai
bug: openai/openai-node#553Change Type
Testing
To test this workaround:
ChatCompletionMessage
with role=assistant is not received.Further testing should be done using different reverse proxy setups to ensure the workaround is robust across various scenarios.
Test Configuration:
Checklist