rack-mini-profiler: Mini Profiler UI not displayed when the response is JSON
In a Rails JSON API, the profiler UI is not displayed, which is unfortunate!
A workaround is easy though; you need two tabs open - one for the JSON, one for the profiler. The second tab needs to be any page that renders HTML (for example the root route /). Make the JSON request, then refresh the page that renders HTML, and the profiler UI will show the JSON request.
Can this be fixed so that the profiler UI shows up on JSON-only pages, or is this by design (and why)?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 20 (6 by maintainers)
@oyeanuj / @printercu the workaround is in the OP use two browser windows, one open to an HTML page.
I think we should ship a blank page people can just hit so you can do
http://myapp.com/rack-mini-profiler/requestsor something to see everything. Then you don’t have to roll out your own blank page.@SamSaffron or others around, what is the recommended way of using rack-mini-profiler with Rails in API only mode?
A custom page that does a req say every 5-10 seconds to update the list should do the trick without enormous amounts of added complexity. Alternatively you could use message bus on such a page.
Totally support shipping a sample or even a custom page for dealing with this.
I’m trying to update #396, but I got a trouble. After getting
/rack-mini-profiler/requests, my puma shows bellow logs.Then puma don’t receive any commands and other requests vanish. Do you have any idea to debug this problem?
It’s impossible for the profiler to show up on JSON requests, because the browser only expects JSON. For HTML requests, we insert JS to render the profiler.
The only way to get around that is by making rack-mini-profiler a browser extension, but that’s a huge amount of work.
@rinkei @jvalenciag I was able to reproduce this “error” you got but I don’t think it’s a legit error. If you go to
/rack-mini-profiler/requestsand see Mini Profiler speed badge on the page, then it is working as expected. Though I’ve opened https://github.com/MiniProfiler/rack-mini-profiler/pull/453 to make the error go away.@OsamaSayegh can you test this out? I would like to make sure
/requestsroute works it makes it practical to debug json only sites.Maybe it’s possible to add new
?pp=flag which will suppress application output and render profiler layout for that request?