Skip to content

broadcaster: rebuild the Xbox Live client after a failed session re-create - #36

Closed
HashimTheArab wants to merge 3 commits into
mainfrom
fix/rebuild-xbl-client-after-rta-loss
Closed

broadcaster: rebuild the Xbox Live client after a failed session re-create#36
HashimTheArab wants to merge 3 commits into
mainfrom
fix/rebuild-xbl-client-after-rta-loss

Conversation

@HashimTheArab

@HashimTheArab HashimTheArab commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Blocked on HashimTheArab/go-xsapi#28. This PR pins that branch so CI can run; once #28 merges into lunar, the pin moves to the merged commit before this lands.

Why

During the 2026-09-02 Xbox Live outage the eu-central and eu-west broadcasters lost their RTA WebSocket. rta.Conn gave up after its short redial budget and closed itself, and from then on every re-announce session failed with the same rta: reconnect: max reconnect attempt (4) reached. recreateSession rebuilt signaling, the session, and the listener, but reused the cached xsapi.Client and with it the dead RTA connection, so the broadcaster looped on that error every two minutes until the pod was restarted by hand. Friend requests kept being accepted while the invites failed with no active MPSD session.

What changed

  • recreateSession tracks consecutive failures. Once a rebuild has already failed, the next one first closes and forgets the primary Xbox Live client the broadcaster created, so the rebuild dials a fresh client (and a fresh RTA connection) through the existing lazy paths. Derived Minecraft token sources are cleared the same way closeCreatedXBLClientReferences already does at shutdown. A caller-supplied client is never touched.
  • The go-xsapi pin moves to the branch from Use xsapi-owned social and presence clients #28, where rta.Conn keeps reconnecting with capped backoff instead of closing itself. That is the primary fix; this change is the safety net for any other way a connection can end up closed.

Sub-account clients keep their own RTA connections and are not rebuilt here; they will benefit from #28 directly.

Tests

go test ./... passes. The new test drives two consecutive failed rebuilds through a failing signaling factory and checks that the created client is closed and forgotten only after the second failure, and that a caller-owned client is kept.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GMfvFUjXaF2P5m2gUmAJaT

Summary by CodeRabbit

  • Bug Fixes

    • Improved session recovery after repeated rebuild failures by refreshing broadcaster-created Xbox Live connections.
    • Preserved caller-owned Xbox Live clients during recovery attempts.
    • Ensured failed connections are closed and cleared before establishing a fresh connection.
  • Tests

    • Added coverage for repeated session rebuild failures and client ownership handling.

…reate

recreateSession rebuilt signaling, session, and listener but reused the
cached xsapi client, so a dead RTA connection inside it failed every
re-announce identically and the broadcaster looped on the same error
every two minutes until the pod was restarted.

Once a rebuild has already failed, the next one first closes and forgets
the primary client the broadcaster created, so the fresh rebuild dials
Xbox Live again. Caller-owned clients are left alone. The go-xsapi pin
moves to the branch that stops rta.Conn from closing itself after a
short outage.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 191dd138-47df-42d7-b20f-023941f1356b

📥 Commits

Reviewing files that changed from the base of the PR and between 1f84aa1 and 14df31a.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 35b297b0-da48-4de0-b13d-f5bc64b9f1b4

📥 Commits

Reviewing files that changed from the base of the PR and between fe96e8d and 1f84aa1.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • broadcaster.go
  • broadcaster_test.go
  • go.mod

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

recreateSession now tracks consecutive failures and discards broadcaster-created primary Xbox Live clients after repeated failures. Tests verify cleanup and caller-owned client preservation. The Xbox Live API replacement version also changed.

Changes

Session recreation

Layer / File(s) Summary
Failure tracking and client cleanup
broadcaster.go, go.mod
recreateSession tracks consecutive failures, closes and forgets broadcaster-created primary clients after a prior failure, and preserves caller-owned clients. The Xbox Live API replacement version changed.
Client ownership regression coverage
broadcaster_test.go
The test verifies repeated-failure cleanup, cleared client references, and caller-owned client preservation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🟡 Moderate · up to 1f84a

The PR rebuilds broadcaster-owned Xbox Live clients after repeated session-recreation failures, improving recovery, but failed cleanup can leave an authenticated connection orphaned while later retries create replacements. Merge should wait for retryable cleanup ownership or explicit acceptance of this bounded security and availability risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rebuilding the cached Xbox Live client after a failed session recreation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rebuild-xbl-client-after-rta-loss

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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