fix(perf): the performance sender reconnects when Windows aborts a kept connection #1299

Open
dukenheimer wants to merge 2 commits from dukenheimer/Longshot:fix/perf-report-aborted into main
Contributor

Type: fix · Risk: low · Tested on: Windows 11 (the sender and its check); Linux (WSL Ubuntu 24.04), the check · Needs: none

Why

With the performance statistics on, the launcher sends the game's waiting summaries at its start, all over one kept
connection. If the relay lets that connection go between two summaries, the sender should reconnect and go on. On
Linux it does. On Windows it stops: Windows reports the dropped connection as ConnectionAbortedError (WinError
10053), which the sender didn't count as a dropped connection. It sends one summary, and the rest wait until the
launcher's next start (and past 48, the oldest are dropped). tests/test_perf_report.py has failed on Windows since
#983 brought the sender ("{'sent': 1, 'refused': 0, 'left': 2}"), and it passes on Linux.

#1265 is about the same sender for other causes (404 and redirects deleting summaries, overlapping senders, the
sending rate). This PR doesn't touch those parts (answer(), the lock, LONGSHOT_PERF_MAX_SENDS).

Prior work: none found (searched ConnectionAbortedError, 10053, perf_report, "performance report sender"; #1277
lists test_perf_report.py among Windows' failures on main but doesn't change the sender).

How to reproduce

Seen on: Windows 11, Python 3.14 (any GPU: the launcher's sender, not the game)
Settings and switches: the performance statistics' tick on (send=1 in longshot_perf.ini), more than one summary waiting
Steps: On main, on Windows, run python -I -B tests/test_perf_report.py --cxx <clang++>, or send to a local relay that closes the kept connection after its first answer: LONGSHOT_PERF_URL=http://127.0.0.1:<port>/perf python -I nx2/perf_report.py <game folder> --send
Expected: every summary sent: the second on a new connection, none twice
Actual: {'sent': 1, 'refused': 0, 'left': 2}: the reused connection's request raises ConnectionAbortedError(10053), which falls through to "later"

What changed

The sender now treats ConnectionAbortedError like the other errors of a dropped kept connection. It sends that
summary once more on a new connection and goes on, on Windows as on Linux.

  • sender: Relay.post() in nx2/perf_report.py: ConnectionAbortedError joins RemoteDisconnected, BrokenPipeError and ConnectionResetError. The retry is unchanged: once, only on a reused connection.
  • tests: tests/test_perf_report.py (first commit) gets a case where the connection raises ConnectionAbortedError(10053) at a kept connection's next request. That is Windows' behavior, simulated, so the case fails on main on any OS. It expects 3 sent, in order, none twice, over 3 connections.

Measurements

Verdict: fixed. The new case fails on main on Windows and Linux and passes here. The existing "dropped" case fails 3 of 3 on Windows on main and passes 3 of 3 here. The real sender sends all 3 where main sent 1.

Hardware: Windows 11, Python 3.14, clang 23.1.5 (llvm-mingw, the Builder's) for the check's C++ part; WSL Ubuntu 24.04, Python 3.12, g++ 13.3
Scene: none: the launcher's sender and game-free checks
Method: python -I -B tests/test_perf_report.py --cxx <compiler>, 3 runs on Windows and 1 on Linux per commit; the real nx2/perf_report.py <folder> --send once per commit against a local relay (the test's stand-in) that drops the kept connection after its first answer, 3 summaries waiting. The PR was rebased onto main @ f88e6e3a (#1291 and #1288, which touch neither the sender nor its check); the check was run again there on both commits, with the same result. The other runs were on the earlier main, 8e9cfc3a.
How to reproduce: the commands above, on the first commit (main plus the test) and on this PR

Before: main @ f88e6e3a After: this PR @ e815a028
"dropped" case, Windows FAIL 3/3: sent 1, left 2 ok 3/3: sent 3
new "aborted" case, Windows FAIL: sent 1, left 2 ok 3/3: sent 3
"dropped" case, Linux ok ok
new "aborted" case, Linux FAIL: sent 1, left 2 ok
perf_report.py --send, Windows, relay drops the connection sent 1, 2 left waiting sent 3, none twice, 0 waiting
Before: main (with the test: c7896945 on f88e6e3a; ead1311e on 8e9cfc3a), Windows
FAIL a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2})
FAIL a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2})
2 failed

Before, Linux (WSL Ubuntu 24.04)
ok   a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0})
FAIL a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2})
1 failed

The sender on main, traced: request ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None)
main:   stdout: {'sent': 1, 'refused': 0, 'left': 2} | relay got [0] on 1 connections | still waiting: 2

After: this PR (e815a028; b197a1b8 before the rebase), Windows (each of 3 runs) and Linux
ok   a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0})
ok   a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0})
all passed
branch: stdout: {'sent': 3, 'refused': 0, 'left': 0} | relay got [0, 1, 2] on 2 connections | still waiting: 0

Flags and settings

None

Testing

Tested:

  • Windows 11: tests/test_perf_report.py (with its C++ part, clang 23), 3 runs on each commit (table above).
  • Linux, WSL Ubuntu 24.04 (g++ 13.3, Python 3.12): tests/test_perf_report.py once on each commit.
  • The real sender on Windows: python -I nx2/perf_report.py <folder> --send with LONGSHOT_PERF_URL set to a local relay that drops the kept connection, the way the launcher starts it. Main sent 1 and left 2 waiting; this PR sent 3, none twice.
  • python -I -B tests/run_all.py --changed after the rebase: 2 passed (test_perf_report.py, byte_compile_tracked.py).
  • python -I -B tests/run_all.py (Windows 11, clang 23, 12 jobs): 616 passed, 45 failed, 52 skipped. None fails because of this PR. test_hardware_report and test_bug_report failed only because Tooling isn't beside this worktree; they pass with MAGICBEAN_TOOLING set. With it set, the failing checks rerun on main @ 8e9cfc3a (this PR's base before the rebase), a clean checkout: main fails 44. This PR fails 43: the same, less test_perf_report.py. That leaves test_menu_i18n.py (main's menu counts, fixed separately on dukenheimer:fix/menu-pt-br-count) and these 42, which fail on main alike on this PC: test_auto_handheld.py, test_bug_report_defaults.py, test_cpu_report.py, test_crash_dialog.py, test_crt_options.py, test_damage_debug_menu.py, test_discover.py, test_display_startup_failure.py, test_dlss_feature_size.py, test_failed_compile_keeps_objects.py, test_framegen_preset.py, test_fsr_uniform_ownership.py, test_guest_imported.py, test_hud_layout_row.py, test_import_reach.py, test_invalidate_vcore.py, test_job_queue.py, test_lift_lookups.py, test_linux_preflight.py, test_linux_pressure.py, test_mirror_budget.py, test_missing_nup.py, test_pads_after_menu.py, test_parallel_init_order.py, test_pending_guest_import.py, test_pipeline_play_cache.py, test_present_thread.py, test_profiling_mode.py, test_readback_timeout_source.py, test_replay_write_order.py, test_rumble_menu.py, test_run_all_changed.py, test_slow_frames.py, test_staging_burst.py, test_target_image_pool.py, test_tested_configurations.py, test_upscaler_round_trip.py, test_upscaler_rows.py, test_vcore_escape.py, test_vk_occlusion_queries.py, test_walk_key.py, test_walk.py.

Not tested: The live relay (data-services.magicbean.dev): when it drops a kept connection depends on its keep-alive timeout, which is why the check uses a local relay. The launcher itself wasn't started; it runs this same --send command.

Must be tested:

  • None

Risks

What could break: If a connection were aborted after the relay had taken a summary but before its answer arrived, that summary could be sent twice. ConnectionResetError already has this risk, and the retry happens once, only on a reused connection.

Turning it off: revert the commit

Compatibility: Nothing changes: no file format, switch or address changes. Summaries already waiting are sent at the next launcher start as before.

Issues

See #1265

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
**Type:** fix · **Risk:** low · **Tested on:** Windows 11 (the sender and its check); Linux (WSL Ubuntu 24.04), the check · **Needs:** none ## Why With the performance statistics on, the launcher sends the game's waiting summaries at its start, all over one kept connection. If the relay lets that connection go between two summaries, the sender should reconnect and go on. On Linux it does. On Windows it stops: Windows reports the dropped connection as `ConnectionAbortedError` (WinError 10053), which the sender didn't count as a dropped connection. It sends one summary, and the rest wait until the launcher's next start (and past 48, the oldest are dropped). `tests/test_perf_report.py` has failed on Windows since #983 brought the sender ("{'sent': 1, 'refused': 0, 'left': 2}"), and it passes on Linux. #1265 is about the same sender for other causes (404 and redirects deleting summaries, overlapping senders, the sending rate). This PR doesn't touch those parts (`answer()`, the lock, `LONGSHOT_PERF_MAX_SENDS`). Prior work: none found (searched `ConnectionAbortedError`, `10053`, `perf_report`, "performance report sender"; #1277 lists `test_perf_report.py` among Windows' failures on main but doesn't change the sender). ## How to reproduce **Seen on:** Windows 11, Python 3.14 (any GPU: the launcher's sender, not the game) **Settings and switches:** the performance statistics' tick on (`send=1` in `longshot_perf.ini`), more than one summary waiting **Steps:** On main, on Windows, run `python -I -B tests/test_perf_report.py --cxx <clang++>`, or send to a local relay that closes the kept connection after its first answer: `LONGSHOT_PERF_URL=http://127.0.0.1:<port>/perf python -I nx2/perf_report.py <game folder> --send` **Expected:** every summary sent: the second on a new connection, none twice **Actual:** `{'sent': 1, 'refused': 0, 'left': 2}`: the reused connection's `request` raises `ConnectionAbortedError(10053)`, which falls through to "later" ## What changed The sender now treats `ConnectionAbortedError` like the other errors of a dropped kept connection. It sends that summary once more on a new connection and goes on, on Windows as on Linux. - sender: `Relay.post()` in `nx2/perf_report.py`: `ConnectionAbortedError` joins `RemoteDisconnected`, `BrokenPipeError` and `ConnectionResetError`. The retry is unchanged: once, only on a reused connection. - tests: `tests/test_perf_report.py` (first commit) gets a case where the connection raises `ConnectionAbortedError(10053)` at a kept connection's next request. That is Windows' behavior, simulated, so the case fails on main on any OS. It expects 3 sent, in order, none twice, over 3 connections. ## Measurements **Verdict:** fixed. The new case fails on main on Windows and Linux and passes here. The existing "dropped" case fails 3 of 3 on Windows on main and passes 3 of 3 here. The real sender sends all 3 where main sent 1. Hardware: Windows 11, Python 3.14, clang 23.1.5 (llvm-mingw, the Builder's) for the check's C++ part; WSL Ubuntu 24.04, Python 3.12, g++ 13.3 Scene: none: the launcher's sender and game-free checks Method: `python -I -B tests/test_perf_report.py --cxx <compiler>`, 3 runs on Windows and 1 on Linux per commit; the real `nx2/perf_report.py <folder> --send` once per commit against a local relay (the test's stand-in) that drops the kept connection after its first answer, 3 summaries waiting. The PR was rebased onto main @ f88e6e3a (#1291 and #1288, which touch neither the sender nor its check); the check was run again there on both commits, with the same result. The other runs were on the earlier main, 8e9cfc3a. How to reproduce: the commands above, on the first commit (main plus the test) and on this PR | | Before: main @ f88e6e3a | After: this PR @ e815a028 | |---|---|---| | "dropped" case, Windows | FAIL 3/3: sent 1, left 2 | ok 3/3: sent 3 | | new "aborted" case, Windows | FAIL: sent 1, left 2 | ok 3/3: sent 3 | | "dropped" case, Linux | ok | ok | | new "aborted" case, Linux | FAIL: sent 1, left 2 | ok | | `perf_report.py --send`, Windows, relay drops the connection | sent 1, 2 left waiting | sent 3, none twice, 0 waiting | ``` Before: main (with the test: c7896945 on f88e6e3a; ead1311e on 8e9cfc3a), Windows FAIL a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2}) FAIL a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2}) 2 failed Before, Linux (WSL Ubuntu 24.04) ok a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0}) FAIL a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 1, 'refused': 0, 'left': 2}) 1 failed The sender on main, traced: request ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None) main: stdout: {'sent': 1, 'refused': 0, 'left': 2} | relay got [0] on 1 connections | still waiting: 2 After: this PR (e815a028; b197a1b8 before the rebase), Windows (each of 3 runs) and Linux ok a kept connection the relay let go: the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0}) ok a kept connection aborted (ConnectionAbortedError): the next summary on a new one, none sent twice ({'sent': 3, 'refused': 0, 'left': 0}) all passed branch: stdout: {'sent': 3, 'refused': 0, 'left': 0} | relay got [0, 1, 2] on 2 connections | still waiting: 0 ``` ### Flags and settings None ## Testing **Tested:** - Windows 11: `tests/test_perf_report.py` (with its C++ part, clang 23), 3 runs on each commit (table above). - Linux, WSL Ubuntu 24.04 (g++ 13.3, Python 3.12): `tests/test_perf_report.py` once on each commit. - The real sender on Windows: `python -I nx2/perf_report.py <folder> --send` with `LONGSHOT_PERF_URL` set to a local relay that drops the kept connection, the way the launcher starts it. Main sent 1 and left 2 waiting; this PR sent 3, none twice. - `python -I -B tests/run_all.py --changed` after the rebase: 2 passed (`test_perf_report.py`, `byte_compile_tracked.py`). - `python -I -B tests/run_all.py` (Windows 11, clang 23, 12 jobs): 616 passed, 45 failed, 52 skipped. None fails because of this PR. `test_hardware_report` and `test_bug_report` failed only because Tooling isn't beside this worktree; they pass with `MAGICBEAN_TOOLING` set. With it set, the failing checks rerun on main @ 8e9cfc3a (this PR's base before the rebase), a clean checkout: main fails 44. This PR fails 43: the same, less `test_perf_report.py`. That leaves `test_menu_i18n.py` (main's menu counts, fixed separately on dukenheimer:fix/menu-pt-br-count) and these 42, which fail on main alike on this PC: `test_auto_handheld.py`, `test_bug_report_defaults.py`, `test_cpu_report.py`, `test_crash_dialog.py`, `test_crt_options.py`, `test_damage_debug_menu.py`, `test_discover.py`, `test_display_startup_failure.py`, `test_dlss_feature_size.py`, `test_failed_compile_keeps_objects.py`, `test_framegen_preset.py`, `test_fsr_uniform_ownership.py`, `test_guest_imported.py`, `test_hud_layout_row.py`, `test_import_reach.py`, `test_invalidate_vcore.py`, `test_job_queue.py`, `test_lift_lookups.py`, `test_linux_preflight.py`, `test_linux_pressure.py`, `test_mirror_budget.py`, `test_missing_nup.py`, `test_pads_after_menu.py`, `test_parallel_init_order.py`, `test_pending_guest_import.py`, `test_pipeline_play_cache.py`, `test_present_thread.py`, `test_profiling_mode.py`, `test_readback_timeout_source.py`, `test_replay_write_order.py`, `test_rumble_menu.py`, `test_run_all_changed.py`, `test_slow_frames.py`, `test_staging_burst.py`, `test_target_image_pool.py`, `test_tested_configurations.py`, `test_upscaler_round_trip.py`, `test_upscaler_rows.py`, `test_vcore_escape.py`, `test_vk_occlusion_queries.py`, `test_walk_key.py`, `test_walk.py`. **Not tested:** The live relay (`data-services.magicbean.dev`): when it drops a kept connection depends on its keep-alive timeout, which is why the check uses a local relay. The launcher itself wasn't started; it runs this same `--send` command. **Must be tested:** - None ## Risks **What could break:** If a connection were aborted after the relay had taken a summary but before its answer arrived, that summary could be sent twice. `ConnectionResetError` already has this risk, and the retry happens once, only on a reused connection. **Turning it off:** revert the commit **Compatibility:** Nothing changes: no file format, switch or address changes. Summaries already waiting are sent at the next launcher start as before. ## Issues See #1265 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened.
On Windows a kept connection the relay let go raises ConnectionAbortedError
(WinError 10053) at the next request, not RemoteDisconnected, and
Relay.post() in nx2/perf_report.py doesn't take it as a dropped connection:
the summary waits, and so do the rest, until the launcher's next start. The
existing "dropped" case shows it on Windows only; this one raises the same
error from the connection on any OS. Fails on main on Windows and Linux:
{'sent': 1, 'refused': 0, 'left': 2}.

Assisted-by: GitHub Copilot (Claude Opus 5.5)
Co-authored-by: Copilot App <[email protected]>
fix(perf): the performance sender reconnects when Windows aborts a kept connection
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
e815a02880
When the relay lets a kept connection go, Windows raises ConnectionAbortedError
(WinError 10053) at the next request where Linux raises RemoteDisconnected.
Relay.post() in nx2/perf_report.py caught only RemoteDisconnected,
BrokenPipeError and ConnectionResetError, so on Windows the summary went to
"later", the sending stopped there, and the summaries left waited for the
launcher's next start. It is now one of them: the summary is sent once more on a
new connection, as on Linux.

Assisted-by: GitHub Copilot (Claude Opus 5.5)
Co-authored-by: Copilot App <[email protected]>
Author
Contributor

Tested in game: not run by the game: the launcher's sender, run as python -I nx2/perf_report.py --send against a local relay that drops kept connections, Windows 11: 3 sent, none twice (main: 1 sent, 2 left)

Tested in game: not run by the game: the launcher's sender, run as python -I nx2/perf_report.py <folder> --send against a local relay that drops kept connections, Windows 11: 3 sent, none twice (main: 1 sent, 2 left)
TrashPanda approved these changes 2026-11-17 02:02:18 +00:00
TrashPanda left a comment

With performance statistics on, Windows drops the sender's kept connection as ConnectionAbortedError (WinError 10053). The sender treated that as "try later" and left the rest of the summaries until the next launch. I read head e815a028. Approved.

Relay.post already retried once, and only when the connection had been reused, for RemoteDisconnected, BrokenPipeError and ConnectionResetError. ConnectionAbortedError now takes that same path. A failure on a new connection still waits. A summary the relay accepted and then aborted before the answer could be sent twice, which ConnectionResetError already risked, and the retry still happens only once.

The new case uses the real sender. A kept connection raises ConnectionAbortedError on its next request, and three summaries go out in order on three connections. It fails on main on Linux as well as Windows. The live relay was not used. The launcher was not started. It runs this same send.

This does not cover the other sender faults in #1265.

With performance statistics on, Windows drops the sender's kept connection as `ConnectionAbortedError` (WinError 10053). The sender treated that as "try later" and left the rest of the summaries until the next launch. I read head `e815a028`. Approved. `Relay.post` already retried once, and only when the connection had been reused, for `RemoteDisconnected`, `BrokenPipeError` and `ConnectionResetError`. `ConnectionAbortedError` now takes that same path. A failure on a new connection still waits. A summary the relay accepted and then aborted before the answer could be sent twice, which `ConnectionResetError` already risked, and the retry still happens only once. The new case uses the real sender. A kept connection raises `ConnectionAbortedError` on its next request, and three summaries go out in order on three connections. It fails on main on Linux as well as Windows. The live relay was not used. The launcher was not started. It runs this same send. This does not cover the other sender faults in https://git.magicbean.dev/MagicBeanDev/Longshot/issues/1265.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 9s
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/perf-report-aborted:dukenheimer-fix/perf-report-aborted'
git switch 'dukenheimer-fix/perf-report-aborted'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1299
No description provided.