Repository navigation
Give the backend calls a deadline - #266
Merged
Merged
Conversation
http::get and http::post connected with TcpStream::connect and read with read_to_string, neither of which has a timeout. A backend that accepts the connection and then never answers blocks the caller forever. The caller that matters is the tray ticker. self_heal_from_backend runs inside spawn_ticker, which is tauri::async_runtime::spawn, so a hung read pins a Tokio worker and the menu-bar pill stops updating until the app is restarted. That is the exact outcome the surrounding code already works to prevent. Its catch_unwind comment says a single bad frame would otherwise freeze the menu-bar pill indefinitely until the user restarts the app. The guard covers panics; a hang arrived through the other door, and for a local HTTP call it is the more likely of the two. toggle_timer makes the same call on its own thread, so there it leaks a thread rather than freezing the tray. Five seconds on connect, read and write. The crate had no tests; it has two. connect_to takes the address so the test drives the real function rather than a copy of it: with the timeouts removed, the silent-backend test fails after 30 seconds instead of passing in 5.
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.
http::getandhttp::postconnected withTcpStream::connectand read withread_to_string, neither of which has a timeout. A backend that accepts the connection and then never answers blocks the caller forever.The caller that matters is the tray ticker.
self_heal_from_backend()runs insidespawn_ticker, which istauri::async_runtime::spawn, so a hung read pins a Tokio worker and the menu-bar pill stops updating until the app is restarted.That is the exact outcome the surrounding code already works to prevent. Two comments in
spawn_tickerexplain thecatch_unwindguards:The guard covers panics. A hang arrived through the other door, and a blocking socket read with no deadline is the more likely of the two for a local HTTP call.
toggle_timerhas the same call on its ownstd::thread::spawn, so there it leaks a thread rather than freezing the tray.Five seconds on connect, read and write. Generous for a local FastAPI answering
/api/clocks/active, short enough that a stuck one costs a single tick.Tests. The crate had none; it has two now.
connect_totakes the address so the test drives the real function rather than a copy of it — with the timeouts removed,a_silent_backend_does_not_block_foreverfails after 30 seconds instead of passing in 5.