Skip to content

MCP Server Health Check False Positive on WSL2 - Port 3684 incorrectly reported as down #41

@Yuutakasan

Description

@Yuutakasan

MCP Server Health Check False Positive on WSL2

Bug Description

dev3000 starts successfully, launches the browser, and the application works correctly, but after ~10 seconds it shuts down due to a false positive health check failure claiming "Port 3684 is no longer in use" even though the MCP server is still running.

Environment

  • dev3000 version: 0.0.84
  • Node.js: v20.19.1
  • npm: 11.4.1
  • OS: WSL2 (Windows Subsystem for Linux 2)
    • Kernel: 6.6.87.2-microsoft-standard-WSL2
    • Distribution: Ubuntu 22.04
  • Project: Next.js 15.5.2 with Turbopack

Steps to Reproduce

  1. Run dev3000 with --debug flag on WSL2:

    dev3000 --port 4321 --debug
  2. Wait for the application to start successfully:

    • ✅ Next.js server starts on port 4321
    • ✅ MCP server starts on port 3684
    • ✅ Chromium browser launches
    • ✅ Application renders correctly
    • ✅ "Development environment ready!" message appears
  3. Observe shutdown after ~10 seconds:

    [DEBUG] Health check failed: Port 3684 is no longer in use
    ⚠️ Critical processes no longer detected. Shutting down gracefully...
    

Expected Behavior

dev3000 should continue running since:

  • The MCP server process is still alive
  • Port 3684 is still listening
  • The Next.js application is functioning correctly

Actual Behavior

dev3000 shuts down with:

[DEBUG] Health check failed: Port 3684 is no longer in use
⚠️ Critical processes no longer detected. Shutting down gracefully...
🛑 Shutting down dev3000 due to critical failure...

Evidence

After shutdown, the MCP server is still running:

$ lsof -i :3684 2>/dev/null || fuser 3684/tcp 2>/dev/null
# Returns valid PIDs - server is still alive

$ curl http://localhost:3684
# Returns successful response

MCP server logs show successful startup:

[MCP-STDOUT] > dev3000-mcp-server@1.0.0 start
[MCP-STDOUT] > next start
[MCP-STDOUT] ▲ Next.js 15.5.1-canary.30
[MCP-STDOUT] - Local:        http://localhost:3684
[MCP-STDOUT] ✓ Ready in 297ms

Additional Context

Timeline from Debug Logs

  1. 00:38:59 - MCP server starts successfully on port 3684
  2. 00:40:13 - Browser navigation complete, app renders
  3. 00:40:19 - Runtime console messages flowing normally
  4. 00:40:28 - Health check fails claiming port 3684 is down
  5. 00:40:28 - dev3000 initiates shutdown

The health check seems to be using an unreliable method for detecting port availability on WSL2.

Workaround Attempted

Using --debug flag successfully avoids the TUI "Raw mode is not supported" error on WSL2, but the health check issue persists.

Suggested Fix

The health check at line 423 of the debug log may need to:

  1. Use a more robust port detection method for WSL2 environments
  2. Add retry logic before declaring a critical failure
  3. Verify the actual process is dead, not just that the port check failed
  4. Use lsof or fuser as fallback detection methods

Related Issues

This appears similar to issues with port detection in containerized or virtualized environments where network namespaces can cause false negatives in port availability checks.

Reproduction Rate

100% reproducible on WSL2 with the configuration above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions