Skip to content

[Port Manager] Open Ports in Menu Bar leaks high-CPU lsof process tree #28217

Closed

Description

@ardaaltinors

Extension

https://www.raycast.com/lucaschultz/port-manager

Raycast Version

1.104.18

macOS Version

15.7.4 (24G517)

Description

The Open Ports in Menu Bar command can leave behind a high-CPU lsof process tree. On my machine, enabling the menu bar command quickly spawned multiple /usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn processes under Raycast Helper (Extensions), with each active lsof process consuming roughly one full CPU core.

I verified the relevant implementation at extensions/port-manager in commit 709e3df645ea4c5748584a5019e8b647510e70f9:

  • open-ports-menu-bar is a menu bar command with "interval": "1m"
  • Process.getCurrent() runs /usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn through child_process.exec
  • I could not find an explicit timeout, child-process cleanup, or in-flight guard around this command

This does not look like a general lsof failure on the machine. Running the same command manually from Terminal completes consistently in about 0.30 seconds.

Environment details:

  • Apple Silicon Mac
  • macOS 15.7.4 (24G517)
  • Raycast 1.104.18
  • Apple /usr/sbin/lsof 4.91
  • OrbStack running
  • Network interfaces include multiple utun, bridge, and vmenet interfaces

Steps To Reproduce

  1. Install and enable Port Manager.

  2. Enable the Open Ports in Menu Bar command.

  3. Wait for background refreshes to run.

  4. Check running lsof processes:

    ps -o pid,ppid,pgid,stat,%cpu,%mem,etime,command -p $(pgrep -x lsof | tr '\n' ' ')
  5. Compare with running the same command manually:

    /usr/bin/time -p /usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn >/tmp/port-manager-lsof.txt

Current Behaviour

When Open Ports in Menu Bar is enabled, Raycast spawns lsof processes under Raycast Helper (Extensions) that can hang or keep running at high CPU.

Observed examples:

Raycast
└─ Raycast Helper (Extensions)
   ├─ /usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn  ~98-100% CPU
   ├─ /usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn  ~98-100% CPU
   └─ ...

During one controlled repro, the process count grew to 5 lsof processes within about 43 seconds, each using roughly 98-100% CPU. Load average climbed significantly.

After disabling Open Ports in Menu Bar, new scheduled launches appeared to stop, but already spawned lsof processes were not cleaned up. Some stale lsof processes remained attached to Raycast Helper (Extensions) and continued consuming CPU or spawning/replacing child lsof processes.

Example after the menu bar command was disabled:

Raycast
└─ Raycast Helper (Extensions) PID 14586
   ├─ lsof PID 29039  ~100% CPU
   └─ lsof PID 20079  sleeping, long-lived
      └─ lsof PID 31096  ~100% CPU

Manual baseline remains fast:

/usr/sbin/lsof +c0 -iTCP -w -sTCP:LISTEN -P -FpcRuLPn
real 0.30
user 0.20
sys 0.09

The only reliable cleanup was manually killing the affected process pattern:

pkill -9 -f 'lsof.*iTCP.*LISTEN'

Expected Behaviour

The menu bar command should not accumulate or leak lsof processes.

Expected safeguards:

  • only one lsof refresh should run at a time
  • a stuck lsof child process should be timed out and terminated
  • disabling the menu bar command should clean up any still-running child process tree
  • background refreshes should not leave orphaned or long-lived high-CPU processes under Raycast Helper (Extensions)
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

    Fields

    Priority

    None yet

    Severity

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions