Skip to content

fix(filestorage): close owned httpx clients after remote sync - #6990

Closed
ump45nose wants to merge 2 commits into
Tracer-Cloud:mainfrom
ump45nose:fix/6989-close-objectstore-httpx
Closed

ump45nose wants to merge 2 commits into
Tracer-Cloud:mainfrom
ump45nose:fix/6989-close-objectstore-httpx

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Summary

Fixes #6989.

AzureBlobObjectStore and VercelBlobObjectStore each built a fresh httpx.Client per run_remote_sync() call and never closed it. Repeated syncs in a long-lived process therefore leaked sockets/FDs until cyclic GC happened to run. VercelBlobObjectStore already tracked _owns_client but never read it.

Changes

  • Add ObjectStore.close() to the protocol.
  • Azure: track _owns_client and close only when the store owns the client.
  • Vercel: implement close() using the existing _owns_client flag.
  • S3-family / GCS: no-op close() (no owned httpx.Client).
  • run_remote_sync() calls store.close() in a finally block.

Test plan

  • pytest tests/filestorage/ — 293 passed
  • New regressions: owned vs injected client close for Azure/Vercel; run_remote_sync closes the built store

AI assistance

AI tools helped draft this change. I reviewed every line, understand the resource ownership, and verified the tests above.

AzureBlobObjectStore and VercelBlobObjectStore built a fresh httpx.Client
per call and never closed it, so repeated run_remote_sync leaked FDs
until cyclic GC. Add ObjectStore.close(), implement it for Azure/Vercel
(honoring _owns_client), no-op for S3-family/GCS, and call it from
run_remote_sync in a finally block.

Fixes Tracer-Cloud#6989
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining test-coverage suggestion is non-blocking.

Findings

  1. P2 Failed-sync cleanup lacks coverage ▶

Summary

The PR closes owned Azure and Vercel HTTP clients after remote sync.

  • Remote syncs close the object stores they build.

Reviews (2) · Last reviewed commit: "fix(filestorage): close ObjectStore fake..." · Reviewed by Greptile

Comment on lines +376 to +378
report = run_remote_sync()
assert report is not None
assert stores and stores[0].closed is True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed-sync cleanup lacks coverage

test_run_remote_sync_closes_store only checks a successful sync. It would still pass if cleanup moved out of finally, leaving clients open whenever a sync fails. Add a case where run_sync raises, then assert that the store closes and the original error reaches the caller.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

CI cli-runtime-3 failed because _FakeObjectStore lacked close(), so the
finally in run_remote_sync raised AttributeError and masked the expected
RuntimeError. Add the no-op on the fake and tolerate a missing close on
legacy stores so a sync failure stays visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Azure/Vercel remote-sync ObjectStore never closes its httpx.Client — FD/connection leak on repeated syncs

2 participants