Skip to content

refactor: extract tool fetch loop body for safe cleanup - #319

Open
IbrahimAhmed8 wants to merge 1 commit into
google:mainfrom
IbrahimAhmed8:fix_cleanup
Open

refactor: extract tool fetch loop body for safe cleanup#319
IbrahimAhmed8 wants to merge 1 commit into
google:mainfrom
IbrahimAhmed8:fix_cleanup

Conversation

@IbrahimAhmed8

@IbrahimAhmed8 IbrahimAhmed8 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

In internal/node/mcp_handlers.go, fetchRemoteToolCatalogue now ensures cleanup occurs per iteration.

The previous implementation was functionally correct but introduced a latent risk. If session.ListTools panics or if a conditional return is introduced later, active streams and sessions would leak

Changes:
Extracted the loop body into a helper method named fetchToolsForRemoteService. This scopes the defer statement to the iteration scope rather than the parent function scope.

A standard defer inside the loop was intentionally avoided to prevent holding all network streams open until function return

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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