[eric] browser: re-broadcast ws commands lost in dead-socket gaps, refetch layout on reconnect

This commit is contained in:
ciregenz
2026-06-04 23:03:20 -07:00
parent 05fa871b24
commit 01e3e2be53
4 changed files with 56 additions and 7 deletions
@@ -58,6 +58,28 @@ async def test_navigate_gets_the_longer_leash(monkeypatch):
assert elapsed > 0.5, "navigate should use its longer bound, not the default"
@pytest.mark.asyncio
async def test_lost_first_delivery_heals_via_rebroadcast(monkeypatch):
# a silently-dead socket eats the first broadcast; the re-send after the
# rebroadcast interval must reach the (reconnected) client and succeed
monkeypatch.setattr(wsm, "_BROWSER_CMD_TIMEOUT_DEFAULT", 5.0)
monkeypatch.setattr(wsm, "_BROWSER_CMD_REBROADCAST_S", 0.1)
m = _mgr()
sends = []
class _CountingSock:
async def send_text(self, payload):
sends.append(payload)
if len(sends) >= 2: # first delivery "lost", second lands
rid = next(iter(m.browser_futures))
m.resolve_browser_command(rid, {"text": "ok"})
m.global_connections = [_CountingSock()]
res = await m.send_browser_command("rid4", "get_text", "b1", {})
assert res == {"text": "ok"}
assert len(sends) >= 2, "command must be re-broadcast until a client answers"
@pytest.mark.asyncio
async def test_a_resolved_command_returns_immediately(monkeypatch):
# a healthy command returns the moment the renderer resolves it, not at the bound