app_profiler icon indicating copy to clipboard operation
app_profiler copied to clipboard

Fix stale profile-running state after `/profile` start conflicts

Open afurm opened this issue 9 months ago • 0 comments

Summary

This fixes a server-side state bug where the profile app could get stuck thinking a profile was running after a failed start/conflict, causing later /profile requests to incorrectly return conflict.

Root Cause

ProfileApplication#start_running set @profile_running = true before attempting AppProfiler.start, but did not reliably reset it when start returned false (conflict) or raised.

Changes

  • Updated start_running to reset @profile_running when AppProfiler.start does not start successfully.
  • Added a rescue path to reset @profile_running before re-raising startup exceptions.
  • Added regression coverage proving profiling works again after an external conflict clears.

Files Changed

  • /Users/afurm/Development/app_profiler/lib/app_profiler/server.rb
  • /Users/afurm/Development/app_profiler/test/app_profiler/profile_server_test.rb

Test Plan

  • bundle exec ruby -Itest test/app_profiler/profile_server_test.rb
  • bundle exec rake test

Both pass locally.

Why This Matters

Without this fix, one conflict event can poison the process-local state and block all subsequent profiling attempts until restart.

afurm avatar Feb 18 '26 18:02 afurm