Skip to content

Guard patch apply when the target project's dev server is running (Turbopack node_modules churn) #109

Description

@alamb-hex

Summary

Applying a patch to a project whose dev server is running breaks that project's dev server. The apply pipeline (/api/projects/[id]/update, and cve-lite --fix via /api/security/cve-lite/[id]/fix) runs pnpm install, which relinks node_modules. A live Turbopack/Next dev server loses its handle to node_modules/next mid-reinstall and panics:

FATAL: An unexpected Turbopack error occurred.
Next.js package not found
- Execution of ... directory_tree_to_loader_tree failed

(The accompanying "inferred your workspace root" message is a misleading symptom — next is still installed; the running process just lost it during the churn.)

When HexOps patches itself (the hexops project in the dashboard is this repo), this is self-inflicted: the dev server you're using to click "Apply" is the one that dies.

How it was hit

Observed while testing the CVE Lite per-finding Apply on the hexops project's qs advisory (see PR #108). The override install churned node_modules while node server.js (Turbopack dev) was live → panic → dev server died. Recovery required rm -rf .next + restart.

Current state

  • "Fix all direct" confirm dialog already warns: "You may need to restart that project's dev server."
  • Per-finding Apply has no such warning.
  • Neither actually prevents the breakage.

Proposed

HexOps already tracks per-project process state (start/stop, metrics). Before an apply:

  1. Detect whether the target project has a running dev server (reuse the start/stop/port tracking).
  2. If running, guard: either
    • warn + require confirmation ("Applying will reinstall dependencies and restart 's dev server"), or
    • offer stop → apply → restart orchestrated by HexOps (cleanest), or
    • at minimum, surface the warning on the per-finding Apply path too (parity with "Fix all direct").
  3. Consider auto-rm -rf .next/dev + restart as part of the orchestrated path so Turbopack comes back clean.

Related

Surfaced during #107 / PR #108 (CVE Lite apply→commit→push). Related to #90 (stop signal propagation) since a clean stop→apply→restart depends on reliable stop.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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