Skip to content

fix(selfhost): make orb-relay-drain resilient to broker degradation - #3984

Merged
JSONbored merged 1 commit into
mainfrom
fix/orb-relay-drain-timeout-resilience
Jul 7, 2026
Merged

fix(selfhost): make orb-relay-drain resilient to broker degradation#3984
JSONbored merged 1 commit into
mainfrom
fix/orb-relay-drain-timeout-resilience

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Replaces fix(selfhost): improve orb-relay-drain robustness against broker degradation #3929, which was corrupted by a bad patch application: it deleted the Authorization: Bearer header on the Orb broker request entirely, left a duplicate signal key, and left src/server.ts in a state that wouldn't even parse (an orphaned if/return outside any function, an undefined drainRelay reference, dangling braces, and the intended setInterval frequency change landing inside the .catch() handler instead of the interval argument) — which is why every build/typecheck-dependent check on that PR was failing.
  • The underlying issue is real: drainOrbRelay's 15s AbortSignal.timeout matched the drain loop's 15s setInterval, so a degraded broker (slow responses or HTTP 500s) caused overlapping drain calls to pile up, plus immediate timeouts with no buffer.
  • Fix: raise the request timeout to 30s (src/orb/broker-client.ts), add an in-flight guard around the drain call so a tick is skipped while the previous drain is still running, and match the poll interval to the new timeout (src/server.ts). The Authorization header and existing error handling are preserved untouched.

Fixes GITTENSORY-1C.

Scope

  • Two files, narrowly scoped to the drain-loop resilience fix.
  • src/server.ts is codecov-exempt (integration/smoke-tested); src/orb/broker-client.ts's changed line was already covered and no test asserts the literal timeout value.

Validation

  • npx tsc --noEmit — clean.
  • npx vitest run test/unit/orb-broker-client.test.ts test/unit/selfhost-monitored-work.test.ts — 57/57 pass.

Safety

  • Authorization: Bearer header on the broker request is preserved (the prior automated PR had dropped it).
  • No secrets/wallets/hotkeys/trust-scores/reward-values touched.

The drain loop's 15s AbortSignal.timeout matched its 15s setInterval, so a
degraded broker (slow responses or HTTP 500s) caused overlapping drain
calls to pile up and immediate timeouts with no buffer. Raise the request
timeout to 30s, add an in-flight guard so a tick is skipped while the
previous drain is still running, and match the poll interval to the new
timeout.

Fixes GITTENSORY-1C.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

1 similar comment
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.70%. Comparing base (283a496) to head (90f891c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3984   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files         373      373           
  Lines       35076    35076           
  Branches    12862    12862           
=======================================
  Hits        32868    32868           
  Misses       1584     1584           
  Partials      624      624           
Files with missing lines Coverage Δ
src/orb/broker-client.ts 99.14% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-07 08:49:11 UTC

2 files · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • AI review already in progress for this PR head: Another Gittensory pass is already running the AI review for this exact PR head. This pass is skipping to avoid a duplicate LLM call.

Review summary
AI review is already running for this PR head in another Gittensory pass. Gittensory is holding this PR for manual review until that pass completes.

Nits — 2 non-blocking
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.
  • AI review already in progress for this PR head — The gate is held for a human reviewer rather than passed automatically; it re-evaluates once the in-flight review completes or on the next update.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers No AI review summary
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 51 registered-repo PR(s), 43 merged, 343 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 343 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 343 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit 92a154b into main Jul 7, 2026
11 checks passed
@JSONbored
JSONbored deleted the fix/orb-relay-drain-timeout-resilience branch July 7, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant