-
Notifications
You must be signed in to change notification settings - Fork 693
Open
Description
Summary
Currently, when Unity performs a domain reload (e.g., after running tests or compiling scripts), the MCP connection drops. The server waits up to 20 seconds for Unity to reconnect before failing commands.
This 20-second timeout handles most domain reloads, but it could cause unnecessary delays in agentic workflows where domain reloads happen frequently.
Current Behavior
UNITY_MCP_SESSION_RESOLVE_MAX_WAIT_Sdefaults to 20 secondsUNITY_MCP_RELOAD_MAX_WAIT_Sdefaults to 20 seconds- Server blindly waits up to 20s when no Unity session is available
Proposed Improvement
Make detection more deterministic by:
-
Detecting Unity's actual reload state rather than blindly waiting
- Check the status file for "reloading" state
- Monitor for connection attempts during the wait period
- Use exponential backoff with early exit when connection is established
-
Shorter default with smart detection
- Default to ~5-10 seconds for normal operations
- Extend only when domain reload is detected (via status file or heuristics)
-
Different timeouts for different contexts
- Post-test-suite: longer timeout expected
- Normal commands: shorter timeout preferred
Related
- Fixed in PR Fix WebSocket connection reliability and domain reload recovery #656 (increased from 2s to 20s to handle domain reloads)
- Issue PropertyConversion failures crash command dispatcher while telemetry continues #654 (dispatcher becomes unreachable after test suite)
Files Involved
Server/src/transport/plugin_hub.py-UNITY_MCP_SESSION_RESOLVE_MAX_WAIT_SServer/src/transport/legacy/unity_connection.py-UNITY_MCP_RELOAD_MAX_WAIT_S
Notes
See TODO comment in unity_connection.py around line 786 for context.
Metadata
Metadata
Assignees
Labels
No labels