Repository navigation
Conversation
…dpoint The prompt_async endpoint wraps a fire-and-forget SessionPrompt.prompt() call in hono's stream() helper, which opens a streaming HTTP response that never writes any data before closing. This causes Cloudflare (and other reverse proxies with idle/first-byte timeouts) to return 524 timeout errors, even though the prompt was successfully accepted by the server. Replace with a direct 204 No Content response, which completes atomically and is not susceptible to proxy timeout issues.
Contributor
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
|
Please re-open. |
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.
Issue for this PR
Closes #16180
Type of change
What does this PR do?
The
prompt_asyncendpoint uses Hono'sstream()to wrap a fire-and-forgetSessionPrompt.prompt()call. The stream callback never callsstream.write()— it just fires off the prompt and exits. This opens a chunked transfer-encoding response that writes zero bytes before closing.Behind Cloudflare (100s first-byte timeout, non-configurable on Free/Pro) this causes 524 timeout errors. The frontend then shows "Send failed" and reverts the input, but the prompt was already accepted server-side.
The fix replaces
stream()with a directc.body(null, 204). Sinceprompt_asyncis designed to return immediately (fire-and-forget), it doesn't need streaming — an atomic 204 response completes in milliseconds and isn't susceptible to proxy timeouts.The synchronous
promptendpoint (which legitimately usesstream()to write response data viastream.write()) is unaffected.How did you verify your code works?
stream canceled by remote with error code 0andIncoming request ended abruptly: context canceledon theprompt_asyncpathstream()callback inprompt_asyncnever callsstream.write(), confirming the wrapper serves no purposepromptendpoint which correctly usesstream.write(JSON.stringify(msg))— that one is a legitimate streaming use casestreamimport remains needed by thepromptendpointScreenshots / recordings
N/A — server-side fix, no UI change.
Checklist