Skip to content

Harden preview process cleanup on WSL2 and 9P mounts #6019

Description

@kof

Problem

On WSL2/Windows, a generated Webstudio preview process can survive a previous CLI/MCP session and continue holding files below .webstudio/preview/ through the 9P mount. A later preview regeneration then fails with EPERM while removing or replacing generated files.

This was reported from Claude Code 2.1.222 using Webstudio CLI 0.283.0. Recovery required finding and terminating the Windows-side process through PowerShell.

Desired outcome

Owned preview processes terminate reliably when their CLI/MCP owner stops, disconnects, or exits unexpectedly, and later preview preparation does not fail with opaque filesystem errors when a foreign or orphaned process still owns generated files.

Scope

  • Reproduce under WSL2 with the repository preview lifecycle.
  • Test normal preview.stop, MCP transport disconnect, Ctrl-C/SIGINT, failed multi-call runs, and abrupt parent termination.
  • Identify whether the orphan is the React Router server, npm launcher, browser process, or a descendant process outside the current process group.
  • Stop the complete owned process tree before cleaning generated files.
  • When cleanup still fails, report the locked path, likely owning process/PID where discoverable, and a safe recovery instruction.

Constraints

  • Do not kill unrelated processes sharing a port or executable name.
  • Preserve macOS and Linux process cleanup behavior.
  • Keep generated preview cleanup recoverable and scoped to the linked project.

Acceptance criteria

  • A WSL integration reproducer fails before the fix and passes afterward.
  • No owned preview descendants remain after normal stop or MCP disconnect.
  • Repeated preview start/stop/regenerate cycles do not produce EPERM under the 9P mount.
  • Failure diagnostics identify the locked preview path and provide an actionable recovery path without requiring source inspection.

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