Skip to content

fix(proxy): log pprof serve errors instead of clean shutdowns - #214

Open
a-palamarchuk wants to merge 1 commit into
coder:mainfrom
a-palamarchuk:fix/pprof-serve-error-check
Open

a-palamarchuk wants to merge 1 commit into
coder:mainfrom
a-palamarchuk:fix/pprof-serve-error-check

Conversation

@a-palamarchuk

Copy link
Copy Markdown

Problem

In Server.Start, the pprof goroutine logged an error only when Serve returned http.ErrServerClosed:

if err := p.pprofServer.Serve(ln); err != nil && errors.Is(err, http.ErrServerClosed) {
	p.logger.Error("pprof server error", "error", err)
}

http.ErrServerClosed is the expected result of Stop(). So every clean exit with --pprof logs an error, and real serve failures are dropped silently.

Change

  • Invert the check to !errors.Is(err, http.ErrServerClosed).
  • Move the goroutine body into servePprof(ln) so a test can call it synchronously.
  • Add TestServePprofLogsOnlyUnexpectedErrors, which covers both a clean shutdown and a real serve failure on a closed listener. Both subtests fail on main and pass with this change.

Testing

Before (main) and after (this branch), using boundary --jail-type=landjail --pprof --pprof-port 6061 --disable-audit-logs --log-level info -- sh -c 'sleep 0.3':

# main: every run
level=INFO msg="Serving pprof on existing listener" port=6061
level=ERROR msg="pprof server error" error="http: Server closed"

# this branch: every run
level=INFO msg="Serving pprof on existing listener" port=6061

AI disclosure

I used Claude Code to find the bug and draft the fix. I reviewed the diff and ran the checks above myself.

The pprof goroutine logged an error only when Serve returned
http.ErrServerClosed, which is the expected result of Stop. So every
clean shutdown with --pprof logged "pprof server error: http: Server
closed", and real serve failures were dropped silently.

Invert the check and move the goroutine body into servePprof so a test
can cover both cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant