macOS: sfw-free proxy can busy-loop at ~80% CPU and never exit after mid-request network interruption; copies accumulate

Open
#51 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
macos, node.js

Research direction

Start by reproducing the macOS-only failure with the sfw-free v1.10.0–v1.12.0 proxy during a mid-request interruption, especially across sleep/wake. Inspect the Node SEA proxy's libuv/kqueue event-loop behavior around the dead or half-closed socket. Done means interrupted requests exit cleanly without persistent CPU spin or accumulating proxy processes, while checking whether Linux remains unaffected.

Written by the indexing model from the issue text.

Description

Summary

On macOS, after a mid-request network interruption, sfw-free proxy processes can get stuck in a persistent CPU spin and never exit. I observed 17 accumulated proxy processes at ~80% CPU each after overnight sleep/wake cycles. I could not reproduce the spin on Linux, which points toward a possible macOS/kqueue-specific event-loop issue.

I did a fair amount of digging (details + measurements below) and it looks like a libuv event-loop spin on a dead/half-closed socket that is specific to macOS (kqueue) I could not reproduce it on Linux. I have not been able to pin the exact line.

Possibly related: #38 (runaway processes when npm/npx are globally wrapped) and #25 (signal/lifecycle handling).

Environment
  • macOS (Apple Silicon, arm64)
  • sfw (npm wrapper) v2.0.6
  • sfw-free binary v1.10.0 at the time of the incident; I separately confirmed the cited source is unchanged through v1.12.0 (current latest), so it still applies
  • npm/npx globally wrapped via a PATH shim, so every package-manager call routes through sfw (same setup as #38)
  • Trigger: a background process that ran npm view <pkg>@latest version --prefer-online repeatedly (≈ hourly in this incident), across overnight sleep/wake cycles
Symptoms (observed)

17 sfw-free proxy processes (the Node SEA that spawns the package manager) alive simultaneously. Activity Monitor showed all 17 at 79.6–82.0% CPU; a few rows (instantaneous %CPU and accumulated CPU time):

%CPU   CPU TIME    PROCESS
82.0   17:07.89    sfw-free-macos-arm64
81.7   12:48.21    sfw-free-macos-arm64
81.2   25:18.32    sfw-free-macos-arm64
…      (17 rows total)

ps confirmed all 17 were state R (on-CPU), on the same TTY, ~250 MB RSS, each running:

sfw-free-macos-arm64 npm view <pkg>@latest version --prefer-online
  • Start times were spread ~1/hour across ~19 hours (12:44 PM → 8:05 AM the next day), matching the update-check interval plus overnight sleep/wake.
  • At that moment the machine was at 97% user / 0% idle.
  • The same command run fresh completes in ~2.7s, so this is a state-dependent hang.
Dominant language
No language data
Stars
271
Forks
8
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SocketDev/sfw-free

All issues in SocketDev/sfw-free

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.