Fix: Prevent infinite recursion when closing streamable sessions#11
Fix: Prevent infinite recursion when closing streamable sessions#11joshuasundance-swca wants to merge 2 commits into
Conversation
|
Maybe it will cause other problem! Can help to change to |
|
Thank you for your comment. I thought about the original, with its comment about memory leaks, and made additional changes. Now you'll see this message in the logs:
In the new changes, I think the
All changes are tested for integration with LangChain in a docker compose setup, but as I said, I do not consider myself a strong TypeScript developer and I'm not sure this is the ideal solution. I think it's a great idea to use |
|
Ok, I will process this problem this weekend.🫡 |
|
@joshuasundance-swca Can help to test in your case? |
|
Closing in favor of #12 👀 which I've tested |
Summary
This PR resolves an infinite recursion bug that occurred when closing a streamable HTTP session. Previously, the
transport.onclosehandler calledserver.close(), which recursively triggered another close, resulting in a stack overflow (RangeError: Maximum call stack size exceeded).Details
The
transport.onclosehandler was callingserver.close(), which in turn calledtransport.close(), re-triggeringoncloseand causing infinite recursion.The call to
server.close()has been removed from thetransport.onclosehandler. Now, the handler only cleans up theactiveTransportsmap, allowing the SDK to manage the closing lifecycle as designed.Testing
RangeError: Maximum call stack size exceedederrors observed.Related Issue
Closes #10
Disclaimer
I am not a strong TypeScript developer, and this fix was made with the help of AI assistance. However, based on testing, the change does accomplish the expected behavior and resolves the infinite recursion issue.
If there are any concerns about implementation details, please review and suggest improvements as needed! Thank you. :)