Skip to content

Fake X-Air: a failed listen is tried again instead of waited on forever - #21

Merged
Skeyelab merged 1 commit into
mainfrom
fix/fake-xair-listens-again
Dec 3, 2026
Merged

Skeyelab merged 1 commit into
mainfrom
fix/fake-xair-listens-again

Conversation

@Skeyelab

@Skeyelab Skeyelab commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Refs ericdahl-dev/ShowRecorder#1215

The hang

ShowRecorder run 43502838420 (main, Debug package tests): MixerLinkEndToEndTests.powerCycle failed its first expectation at 20:41:48 (no "Kick" after connect), no line from that test followed, and the job was canceled at its 40-minute limit.

The cause is in the test's fake Mixer, not in Mixer Link:

  1. On the busy runner (every test in that batch took about 39 s) one answer came after the 3 s timeout, so connect failed. The Link then keeps trying by itself (#1209).
  2. The test checked the Sources at once, recorded the failure and went on. Its next step waits for the Link to be down. Normally that takes a timeout, which puts seconds between powerOff() and powerOn(). Here the Link was already down, so powerOn() followed powerOff() at once.
  3. powerOn() listens on the same port again. With a Link still asking, that listen fails: failed(POSIXErrorCode(rawValue: 48): Address already in use). FakeXAirMixer.listen only watched for .ready, so it waited forever. That is the only wait in the test with no bound.

The "about 90 tests that never ended" in the issue are most likely the tail of swift test's buffered output, lost when the job was killed; I could not confirm that from the log.

Reproduced on macOS CI

On a diagnostics draft (#17, never merged), copies of this scenario with the fake listening once, as before, against the fake with this fix:

Run Scenario Listens once (before) Tries again (this PR)
47057027076 (Debug) Link down from late answers, power-off and on at once 4 of 5 never listened again
47058027688 (Debug and Release) same 48 of 48 came back, 43 of them at the second try
47058970721 (Debug, synthetic load) connect failed, Link keeps trying, power-off and on at once 19 of 24 failed to listen (EADDRINUSE)
47058970721 (Debug, synthetic load) Link down from late answers 11 of 12 failed 12 of 12 came back at the second try
47060024639 (Release, no load) the new test's own steps 12 of 12 failed to listen 12 of 12 came back at the second try

An idle fake, with no Link asking, listened again at once 20 times out of 20 (run 47051316745), which is why the test normally passes.

The fix (test code only)

  • FakeXAirMixer.listen tries a failed listen again, 25 ms apart, and throws after 10 s instead of waiting forever. So a fake that cannot listen now fails its test, and cannot hang the run.
  • powerCycle waits for the Link to come up after connect (up to the usual bounded wait) instead of checking at once: the Link retries a failed connect by design.
  • New test powerCycleAtOnce: the connect fails (the fake does not answer), the fake is switched off and on at once, and the Link comes up. Without the fake's fix this test waits forever in powerOn().

No product code changes: a real Mixer's power cycle does not involve this listener, and the Link's own retry worked in every reproduction once the fake was back.

Not verified

  • Why the port is still taken for a moment (which socket of the old listener holds it) was not established; the second try 25 ms later was enough in every run.
  • Not run locally: MixerLink needs Network.framework and this was written on Linux. macOS CI on this PR is the check.
  • ShowRecorder release/1.2 keeps its own copy of the fake and the test and needs the same change by hand.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ

…er (ShowRecorder #1215)

After a power-off the fake Mixer listens on the same port again. When a Link is still asking, that first listen
often fails with EADDRINUSE, and the fake only watched for .ready, so powerOn() never returned: the power-cycle
test hung and the package tests ran into the CI time limit (ShowRecorder run 43502838420).

The test normally waits a timeout for the Link to notice the power-off, which hid this. When its first connect
failed on a busy runner, the Link was already down, the power-on followed the power-off at once, and the listen
failed.

- The fake tries a failed listen again, 25 ms apart, and throws after 10 s instead of waiting forever.
- The power-cycle test waits for the Link to come up after connect: a connect that fails is retried by the
  Link itself (#1209).
- A new test power-cycles the fake at once while the Link keeps trying.

Test code only.

Refs ericdahl-dev/ShowRecorder#1215

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ
@Skeyelab
Skeyelab enabled auto-merge (squash) December 3, 2026 07:41
@Skeyelab
Skeyelab merged commit 2559619 into main Dec 3, 2026
4 checks passed
@Skeyelab
Skeyelab deleted the fix/fake-xair-listens-again branch December 3, 2026 07:49
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Skeyelab added a commit that referenced this pull request Dec 3, 2026
* Fake Mixers listen only on a port that can be reached (ShowRecorder #1248)

macOS can hand a new loopback listener a port that a client used a moment ago to talk to another listener in
the same process. Every new connection to such a port then waits on EADDRINUSE, so a fake Mixer there never
hears its driver: the WING answered its knock and never heard a query, and the Link stayed down for as long
as the test waited.

- Loopback.listen is now the one listener under FakeWing, FakeXAirMixer and FakeTextMixer. It checks that two
  new connections get through to the port and takes another port when they don't.
- It also carries the retry of a failed listen from #21, so the WING and text fakes get that too.
- A new test asks a listener onto a port a client just used.

Test code only.

Refs ericdahl-dev/ShowRecorder#1248

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ

* The probe never sees its own cancel: drop that case

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgWWseQZtUzcSRzjqqQJQ

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant