Skip to content

fix(validator): close MirrorClient session opened for issue discovery#1476

Open
jaso0n0818 wants to merge 1 commit into
entrius:testfrom
jaso0n0818:fix/issue-discovery-mirror-client-leak
Open

fix(validator): close MirrorClient session opened for issue discovery#1476
jaso0n0818 wants to merge 1 commit into
entrius:testfrom
jaso0n0818:fix/issue-discovery-mirror-client-leak

Conversation

@jaso0n0818

Copy link
Copy Markdown

Summary

issue_discovery() (gittensor/validator/forward.py) called run_issue_discovery() without a client, so the client = client or MirrorClient() fallback inside it created a new MirrorClient — and its underlying requests.Session — that was never closed. Issue discovery runs on every scoring round, so each round leaked the session's connection pool (open sockets).

This owns the client at the call site with with MirrorClient() as client: and passes it in, mirroring how forward.build_maintainer_uids_by_repo and reward.evaluate_miner already manage their MirrorClient lifetime. No behavior changes beyond the session now being released.

Related Issues

No issue filed; self-contained resource-leak fix on the issue-discovery path, in the same vein as the per-PR content cleanup in #1456.

Type of Change

  • New feature
  • Bug fix
  • Refactor
  • Documentation
  • Other

Testing

Full gate run locally with uv (Python 3.12):

uv run ruff check / format         # clean
uv run pyright                     # 0 errors
uv run pytest tests/ -q            # 917 passed

No CLI output is affected (change is in gittensor/validator/**, not gittensor/cli/**), so no terminal evidence applies.

Checklist

  • Code follows repository style (ruff lint + format clean)
  • Self-reviewed the diff (mirrors the existing with MirrorClient() as client: pattern in this file)
  • Tests pass (uv run pytest tests/ — 917 passed) and pyright clean
  • No unrelated changes

issue_discovery() called run_issue_discovery() without a client, so the
`client = client or MirrorClient()` fallback inside it created a new
MirrorClient — and its requests.Session — that was never closed. Issue
discovery runs every scoring round, so each round leaked the session's
connection pool.

Own the client at the call site with `with MirrorClient() as client:` and
pass it in, mirroring how forward.build_maintainer_uids_by_repo and
reward.evaluate_miner already manage their MirrorClient lifetime.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant