Skip to content

fix: Fix MCP asyncio error#10074

Closed
dzbanek717 wants to merge 4 commits into
langflow-ai:mainfrom
dzbanek717:fix/mcp-asyncio-error
Closed

fix: Fix MCP asyncio error#10074
dzbanek717 wants to merge 4 commits into
langflow-ai:mainfrom
dzbanek717:fix/mcp-asyncio-error

Conversation

@dzbanek717
Copy link
Copy Markdown

@dzbanek717 dzbanek717 commented Oct 1, 2025

Iterating over dict items in get_session method in mcp utils file causes asyncio errors when using the flow with MCP tooling over API.

image image

After wrapping session.items() in list method the error is gone.

Summary by CodeRabbit

  • Bug Fixes
    • Improved session management to prevent rare runtime errors during cleanup when sessions change mid-iteration. This enhances stability under concurrent operations and ensures reliable session lifecycle handling without altering expected behavior. Users should experience fewer intermittent crashes and more consistent cleanup during long-running or high-activity scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 1, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

get_session now iterates over a static snapshot of the server sessions by wrapping sessions.items() with list(...), allowing safe in-loop modifications without raising RuntimeError. No public interfaces or error handling behavior changed.

Changes

Cohort / File(s) Summary
Session iteration safety
src/lfx/src/lfx/base/mcp/util.py
Replace direct sessions.items() iteration with list(sessions.items()) to avoid RuntimeError when the dict mutates during iteration; no other logic or interfaces changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change by indicating a fix to the MCP asyncio error, aligning with the modifications in the get_session method, and adheres to a clear and concise phrasing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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 and usage tips.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 2, 2025
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 2, 2025

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Oct 2, 2025
@Cristhianzl
Copy link
Copy Markdown
Member

hey @dzbanek717,
thanks for your collaboration!
but we already have this fix in #9901.

@Cristhianzl Cristhianzl closed this Oct 2, 2025
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.

3 participants