Skip to content

fix: XHProf profiler endpoint always detected as Sentry#328

Merged
butschster merged 2 commits intobuggregator:masterfrom
xgarreau:master
Apr 9, 2026
Merged

fix: XHProf profiler endpoint always detected as Sentry#328
butschster merged 2 commits intobuggregator:masterfrom
xgarreau:master

Conversation

@xgarreau
Copy link
Copy Markdown
Contributor

@xgarreau xgarreau commented Apr 9, 2026

Summary

  • Fix /api/profiler/store being intercepted by the Sentry handler (priority 10) before the Profiler handler (priority 40)
  • Fix SQLite single-writer contention: move storeProfile out of Handle() into OnEventStored()
  • Fix stack overflow in flamechart when XHProf data contains recursive call cycles

Root causes

1. Double interception of /profiler/store
detect.go auto-detected any path ending in /store as Sentry, and sentry/handler.go Match() also matched /store independently. Both now exclude paths containing /profiler/.

2. SQLite contention / context canceled
profiler/handler.go was calling storeProfile() inside Handle(), then the pipeline called eventService.Store() — two concurrent writes on a MaxOpenConns(1) connection caused the HTTP context to expire. Moved to OnEventStored().

3. Flamechart stack overflow
buildNode in api.go had no cycle detection. Added a visited map to break cycles.

Test plan

  • POST /api/profiler/store stores as type=profiler
  • Sentry events via /api/1/store still work
  • Flamechart does not crash on recursive XHProf profiles
  • go test ./internal/server/http/ passes

@butschster butschster merged commit 3217e5d into buggregator:master Apr 9, 2026
1 check failed
butschster added a commit that referenced this pull request Apr 9, 2026
After PR #328 moved storeProfile from Handle() to OnEventStored(), the MCP
test's ingestViaHandler helper no longer populated profiler-specific tables.
Add the missing NotifyEventStored call to match the real HTTP server flow.
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.

2 participants