Skip to content

fix(devserver): resolve bridge port polling when controller reuses existing DevServer#22953

Open
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-devserver-cli-bridge-port-polling
Open

fix(devserver): resolve bridge port polling when controller reuses existing DevServer#22953
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-devserver-cli-bridge-port-polling

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

Summary

When the DevServer CLI MCP bridge launches a host process and that process exits
(e.g., a controller that detected an existing DevServer started by Rider/VS),
the bridge was polling its own randomly-chosen port instead of the existing
server's port — resulting in a 30-second timeout and false HostCrashed status.

Closes #22952

What changed

Core fix — AmbientRegistry fallback (DevServerMonitor.cs):

  • After the host process exits during the readiness probe, re-query the
    AmbientRegistry for an active server for the same solution on a different port
  • If found, adopt that server's port and retry the readiness probe on the correct port
  • Clear _serverProcess so DeterminePostStartupAction correctly routes to
    HTTP health polling

Backward compatibility — 404 handling (DevServerMonitor.cs):

  • WaitForServerReadyAsync now returns ReadinessProbeResult instead of bool
  • Distinguishes between: Ready, ProcessExited, ServerRespondedNoMcp (HTTP
    alive but /mcp 404), TimedOut
  • Hosts that respond to HTTP but lack /mcp report Degraded with an actionable
    diagnostic instead of HostCrashed

Stale state fix (DevServerMonitor.cs):

  • HostRespondedNoMcp is reset in StopMonitoringAsync and before each
    readiness probe to prevent stale diagnostics across workspace transitions
    and crash recovery cycles

Decision model (MonitorDecisions.cs):

  • ReadinessProbeResult enum for clean separation of probe outcomes
  • ShouldAttemptAmbientFallback — extracted decision for testability
  • IsReadinessAcceptable — extracted readiness gate for testability

Health diagnostics (HealthReport.cs, HealthReportFactory.cs, HealthService.cs):

  • Added IssueCode.HostMcpEndpointNotAvailable (Warning severity)
  • Surfaces remediation suggesting upgrading the DevServer package

Test plan

  • Unit tests for ShouldAttemptAmbientFallback (5 cases: different port,
    no server, same port, wrong probe result, null solution)
  • Unit tests for IsReadinessAcceptable (all 4 enum values)
  • Unit tests for HostMcpEndpointNotAvailable health issue (present/absent)
  • ReadinessProbeResult enum coverage
  • 70/70 tests pass locally
  • CI validation on hosted_ubuntu, macos, hosted_windows

Copilot AI requested review from Copilot and removed request for Copilot April 2, 2026 15:56
Copilot stopped work on behalf of carldebilly due to an error April 2, 2026 16:11
Copilot AI requested a review from carldebilly April 2, 2026 16:27
Copilot AI requested review from Copilot and removed request for Copilot April 2, 2026 17:27
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 2, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ carldebilly
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

devin-ai-integration[bot]

This comment was marked as resolved.

Copilot AI and others added 3 commits April 2, 2026 14:37
…erver

When the host process exits during the readiness probe (e.g. the
controller detected an existing DevServer started by another IDE),
re-check the AmbientRegistry for an active server on a different
port and adopt it, instead of polling the wrong port for 30 seconds.

Also distinguish between 'server alive but /mcp 404' and 'nothing
listening' during the readiness probe. Hosts that respond to HTTP
but lack the /mcp endpoint now report Degraded with an actionable
HostMcpEndpointNotAvailable diagnostic instead of HostCrashed.

Agent-Logs-Url: https://github.com/unoplatform/uno/sessions/de8ab6cb-512d-4181-a214-b4afa5cc3093

Co-authored-by: carldebilly <4174207+carldebilly@users.noreply.github.com>
…t decisions

- Reset HostRespondedNoMcp in StopMonitoringAsync and before each
  readiness probe to prevent stale diagnostics across workspace
  transitions and crash recovery cycles
- Extract ShouldAttemptAmbientFallback and IsReadinessAcceptable
  into MonitorDecisions for proper testability
- Replace tautological inline-logic tests with tests that exercise
  the extracted decision methods
- Remove fragile enum count assertion
Copilot AI review requested due to automatic review settings April 2, 2026 18:42
@carldebilly carldebilly force-pushed the copilot/fix-devserver-cli-bridge-port-polling branch from 6d787de to b336302 Compare April 2, 2026 18:42
@carldebilly carldebilly changed the title [WIP] Fix DevServer CLI bridge polling wrong port when reusing server fix(devserver): resolve bridge port polling when controller reuses existing DevServer Apr 2, 2026

This comment was marked as resolved.

@carldebilly carldebilly marked this pull request as ready for review April 2, 2026 18:56
@carldebilly carldebilly enabled auto-merge April 2, 2026 19:04
@unoplatform unoplatform deleted a comment from unodevops Apr 2, 2026
@unoplatform unoplatform deleted a comment from azure-pipelines bot Apr 2, 2026
@unodevops
Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22953/wasm-skia-net9/index.html

/// Used by <see cref="HealthService"/> to surface an actionable diagnostic.
/// Reset on stop and at the beginning of each readiness cycle to avoid stale diagnostics.
/// </summary>
public bool HostRespondedNoMcp { get; private set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Updated spec for this change?

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.

DevServer CLI bridge polls wrong port when controller reuses an existing server

7 participants