Skip to content

refactor: remove global DefaultServeMux dependency in pprof server #36277

@luojiyin1987

Description

@luojiyin1987

Description

The servePprof() function in cmd/web.go currently uses http.DefaultServeMux via a blank import of net/http/pprof. This is problematic because:

  1. Isolation: Global mux can be polluted by other packages
  2. Maintainability: Implicit handler registration is harder to track
  3. Security: Other code could accidentally expose endpoints via DefaultServeMux

Proposed Solution

  • Replace blank import _ "net/http/pprof" with explicit import "net/http/pprof"
  • Create a dedicated http.ServeMux for the pprof server
  • Register pprof handlers explicitly

Related

PR: #36276

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