Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR hardens
print_to_webwebsocket response handling so large final markdown payloads are not intermittently lost when the socket closes immediately after the last send.Why this fix
We observed a rare production symptom: after a long Step 3 (e.g.,
"[Step 3] Generating answer... Time: 88s"), logs appeared in the output panel but the final markdown result was occasionally missing.The issue is high impact for long-running LLM calls because users can wait a long time and still receive no final answer.
How we identified the cause
Investigation signals
Code-path findings
print_to_webwrites output frames via websocket and then closes immediately.sys.stdout/sys.stderrreplacement was restored only on the success path, not guaranteed on errors.A/B validation
A deterministic regression test reproduces the loss model:
What changed
Backend (
backend/funix/decorator/call.py)send_ws_json(...)send_ws_done()sends{"__funix_event":"done"}close_ws_with_drain(...)close_ws_with_drainwith default 200ms delay.sys.stdout/sys.stderrare restored in afinallyblock inoutput_to_web_function.send_ws_json.Frontend (
frontend/src/components/FunixFunction/InputPanel.tsx)__funix_event) so they do not overwrite user output.Tests (
backend/funix/test/test_print_to_web_websocket_reliability.py)If problem persists, check these first
Proxy/websocket infrastructure
Client runtime
Server logs and payload shape
Deployment version parity
Payload characteristics
Verification executed
PYTHONPATH: pre-fix fails on final large markdown preservation as expected.