Repository navigation
Commit e626f53
authored
Read a response body only once the browser has finished delivering it (#85)
## Problem
Three `ci` runs on main have now spent the whole 45-minute step bound
and left no failure to read:
[33130006054](https://github.com/max-sixty/leaf/actions/runs/33130006054)
(`45de22f`),
[33130455313](https://github.com/max-sixty/leaf/actions/runs/33130455313)
(`d4472ad`),
[33131937176](https://github.com/max-sixty/leaf/actions/runs/33131937176)
(`caa8460`). Under the `-v` #81 added, each names a different test that
a worker picked up and never reported —
`test_a_resolved_thread_can_be_reopened`,
`test_a_sent_comment_is_revealed_in_the_panel`,
`test_an_answer_carrying_an_older_pick_cannot_undo_a_newer_one` — so the
wedge is not a test's, and the other worker stops minutes later in a
module of its own.
It is `Traffic`.
[`_responded`](https://github.com/max-sixty/leaf/blob/3feb009d654af450fed766621909b1933f96e418/tests/render_harness.py#L629)
queues a response when its **headers** arrive, and
[`settle`](https://github.com/max-sixty/leaf/blob/3feb009d654af450fed766621909b1933f96e418/tests/render_harness.py#L648)
then reads the body with
[`response.json()`](https://github.com/max-sixty/leaf/blob/3feb009d654af450fed766621909b1933f96e418/tests/render_harness.py#L663).
That call waits on the request's finished fact and takes no timeout in
any binding. A page that abandons an answer it no longer wants leaves a
request Chromium never reports finished, and the read then blocks for as
long as the job lives. It is the one wait in this harness that cannot
run out: `_until`'s own 30-second deadline guards `wait_for_event` and
never gets a turn, so the worker stops inside a helper every render test
calls, with no nodeid, no traceback and no Playwright timeout.
This is measured, not inferred — the full suite was run locally under a
call tracer and both workers were caught inside `Response.json`, unmoved
across two snapshots a minute apart (below).
## Solution
Settle a response only once `requestfinished` says the browser holds the
whole body, and wake `_until` on that same fact rather than on arriving
headers — a body is what the counters are read from, and that event is
the browser saying it has one. `settle` keeps an unfinished response
queued instead of reading it, so the shape that used to stop the run now
lets `_until` reach its deadline and print its counters, which is the
naming a wedge could never do.
The counters themselves are untouched: `acked` and `heard` still move on
the `response` event, so what a trip means to `round_trip` is what it
meant before.
This is at a different site from #84, which bounds `page.evaluate`'s
frame promises on the same three runs' evidence and says of itself that
it does not prove which wait wedged them. The two do not overlap in
`render_harness.py`, and #84 still closes a real unbounded-wait class —
it is just not the one that stopped these runs.
## Testing
`uv run pytest tests --run-nightly` — **1357 passed, 6 skipped in
19:36**, on the machine that had just wedged twice in a row at 65% and
91% without the change. Rebased onto `dd42ddb`: `ruff check`, `ruff
format`, `tests/test_render_conversations.py` and
`tests/test_render_reactions.py` (48 passed), and the three traffic-wait
gates.
Bug-back: with `settle` restored to its unconditional drain,
`test_traffic_leaves_a_body_the_browser_has_not_finished_handing_over`
fails with `a body was read before the browser had all of it`.
<details><summary>How the blocking call was identified</summary>
The suite was run as CI runs it (`uv run pytest tests --run-nightly -v`)
with a plugin wrapping the Playwright sync surface — `Page.close`,
`Page.evaluate`, `Page.wait_for_function`, `Response.body/json/text`,
`Locator.*`, `Mouse.*`, `Keyboard.*` — each writing the call it is
inside to a per-worker file. A watchdog snapshotted those files after
the log had been silent for 150 seconds, and again a minute later:
```
--- snapshot A
30159 1787884275.442 ENTER Response.json stack=['Response.json']
27463 1787884129.338 ENTER Response.json stack=['Response.json']
--- snapshot B
30159 1787884275.442 ENTER Response.json stack=['Response.json']
27463 1787884129.338 ENTER Response.json stack=['Response.json']
```
Both workers, unmoved, with the report count frozen at 1315 of 1395.
`py-spy` cannot reach these (the sandbox denies `ptrace`), and
`faulthandler` names nothing here for the reason `pyproject.toml`
records — the test's frames sit in a suspended greenlet.
The wedge reproduces without instrumentation too. An earlier plain run
stopped at 91% with `gw1` inside
`test_a_resolved_thread_can_be_reopened` after
`test_a_thread_the_agent_closed_names_who_closed_it` — the same pair, in
the same order, as run 33130006054. Both wedges left their page server
answering: the served page's `viewed.json` kept ticking every 30
seconds, and `ss` showed one established connection per server with
empty queues, so nothing was stalled on the wire and no `flock` was
held. Per-test pacing in the failed CI runs matches a green run's decile
for decile, which rules out the machine slowing down before it stopped.
</details>
---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/33130006054)
---------
Co-authored-by: leaf-agent <[email protected]>1 parent 6045970 commit e626f53
2 files changed
Lines changed: 109 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
| 602 | + | |
602 | 603 | | |
603 | 604 | | |
604 | 605 | | |
| 606 | + | |
605 | 607 | | |
606 | 608 | | |
607 | 609 | | |
| |||
642 | 644 | | |
643 | 645 | | |
644 | 646 | | |
645 | | - | |
646 | | - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
647 | 650 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
652 | 658 | | |
653 | | - | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
654 | 663 | | |
655 | 664 | | |
656 | 665 | | |
657 | 666 | | |
658 | 667 | | |
659 | 668 | | |
660 | 669 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
665 | 691 | | |
666 | 692 | | |
667 | 693 | | |
| |||
732 | 758 | | |
733 | 759 | | |
734 | 760 | | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
745 | 773 | | |
746 | 774 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
751 | 779 | | |
752 | 780 | | |
753 | 781 | | |
| |||
757 | 785 | | |
758 | 786 | | |
759 | 787 | | |
760 | | - | |
761 | | - | |
| 788 | + | |
| 789 | + | |
762 | 790 | | |
763 | 791 | | |
764 | 792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
1718 | 1719 | | |
1719 | 1720 | | |
1720 | 1721 | | |
1721 | | - | |
1722 | | - | |
| 1722 | + | |
| 1723 | + | |
1723 | 1724 | | |
1724 | 1725 | | |
1725 | 1726 | | |
1726 | 1727 | | |
1727 | 1728 | | |
1728 | 1729 | | |
1729 | 1730 | | |
1730 | | - | |
1731 | | - | |
| 1731 | + | |
| 1732 | + | |
1732 | 1733 | | |
1733 | 1734 | | |
1734 | 1735 | | |
| |||
1738 | 1739 | | |
1739 | 1740 | | |
1740 | 1741 | | |
1741 | | - | |
1742 | | - | |
| 1742 | + | |
| 1743 | + | |
1743 | 1744 | | |
1744 | | - | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
1745 | 1787 | | |
1746 | 1788 | | |
1747 | 1789 | | |
1748 | | - | |
| 1790 | + | |
| 1791 | + | |
1749 | 1792 | | |
1750 | 1793 | | |
1751 | 1794 | | |
| |||
1760 | 1803 | | |
1761 | 1804 | | |
1762 | 1805 | | |
1763 | | - | |
| 1806 | + | |
1764 | 1807 | | |
1765 | | - | |
| 1808 | + | |
1766 | 1809 | | |
1767 | | - | |
| 1810 | + | |
1768 | 1811 | | |
1769 | 1812 | | |
1770 | 1813 | | |
| |||
0 commit comments