Skip to content

fix(sync): limit how long LAN connections and requests can wait - #452

Open
A-EDev wants to merge 3 commits into
mainfrom
fix/sync2-lan-timeouts
Open

A-EDev wants to merge 3 commits into
mainfrom
fix/sync2-lan-timeouts

Conversation

@A-EDev

@A-EDev A-EDev commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Time limits and a connection limit for LAN sessions:

  • Answering side: a connection has 3 seconds to complete the WebSocket handshake and send its first hello, and 3 more for its last one. The roster is replayed only after the first message arrives. At most 16 connections can be at this stage; further ones are closed at once.
  • Accepting: a failed accept, such as running out of descriptors, no longer ends the service. It tries again 100 ms later.
  • Dialing side: waiting for the peer's hello takes at most 3 seconds, and each request at most 30.
  • Run loop: members are dialed in a round beside the loop, up to 8 at a time, so a slow member doesn't stop advertising, browsing or address upkeep.

Related issue

None.

Change type

  • Bug fix

Validation

  • cargo fmt --all: run before committing.
  • cargo test --test sync2_lan in src-tauri: 22 passed, 1 ignored. The 3 new tests that run by default fail on main's code.
  • bash -c 'ulimit -n 256; cargo test --test sync2_lan -- --ignored --exact the_service_keeps_accepting_after_running_out_of_descriptors': passed. It's ignored by default because it needs that limit.
  • cargo test --lib lan_: 13 passed, including the new request limit test, which uses paused time.
  • cargo test --test sync2_hybrid --test sync2_live --test sync2_pairing_channel: passed.
  • Mutations: raising the connection limit fails its test, removing the hello limit fails its test, and removing the request limit makes its test hang until killed at 45 s.
  • cargo clippy --all-targets --all-features: no warning left in lan_link.rs, lan_sync.rs or lan_runtime.rs.
  • CI runs the full suite on this PR.
  • lan_runtime.rs needs an AppHandle and has no test, so the rounds are checked by compiling and reading only.
  • Not run on a real network, in a window or on a device.

Risk and compatibility

No format change, so older and newer devices still meet. The 3-second and 30-second limits are reasoned, not measured on real Wi-Fi. A very long roster on a slow device could take more than 3 seconds to answer a hello; the dialer then tries again on its next round. Anyone on the network can still use the 16 places by reconnecting, which delays members but costs no more than that. Messages before the hello still use the larger LAN frame limit, so 16 connections could briefly hold about 68 MiB. New dev feature: tokio's test-util, for paused time; the lock file doesn't change.

  • No new secrets, private data, telemetry, or broad Tauri permissions were introduced.
  • Dependency and lockfile changes are intentional and limited to this PR.

Copilot AI balanced review requested due to automatic review settings November 7, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants