Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge amount of store_id access has been raised #1725

Closed
heavenshell opened this issue Dec 21, 2022 · 7 comments
Closed

Huge amount of store_id access has been raised #1725

heavenshell opened this issue Dec 21, 2022 · 7 comments

Comments

@heavenshell
Copy link

Hello. Thank you for great works.

I've update to v3.8.1 and found some issue.

When I access to SPA page, which access to server api using axios,
huge amount of access(*) was recorded and Debug toolbar does not show any panel.
* http://localhost:8000/__debug__/history_sidebar/?store_id=03b13fc6002f4d11abd19ca4de7cb732)

Not SPA page(maybe not access to API server via JavaScript), does not happen.

Dose anyone else experienced the same problem?

v3.8.1

v3.8.1.mp4

v3.7.0 works fine.

v3.7.0.mp4

I think this PR #1685 was releated.

OS: macOS X
Django: 3.2.16
React: 17.0.2
axios: 0.27.2

Best regards.

@matthiask
Copy link
Member

Yes, that's almost certainly related to #1685. I'm wondering what's happening here though. I don't see those repeated requests (obviously) and I also work with more or less the same software as you do. Not using axios, but React, Django etc.

One hypothesis which comes to mind is that the toolbar may be loaded more than once and the window.fetch we're calling isn't actually the correct window.fetch but our own, so that we're looping infinitely? Or maybe React re-renders the toolbar because of the DOM change? (No idea why this would happen, though.) I assume that you're not using React to render the whole <body>?

@heavenshell
Copy link
Author

@matthiask Thank you for replay!

Humm, minimum code(below) did not reproduced.
Maybe my Application cause something wrong to debug tool bar.

import axios from 'axios'

const Component = () => {
  axios.get('/api/me/') // Just get profile from Django app's endppint

  return <div>foo</div>
}

const App = () => (
  <Component />
)

render(<App />, document.getElementById('app'))
urlpatterns = [
    path(
        'foo',
        TemplateView.as_view(template_name='a.html'),
        name='foo',
    ),
]
{% load static %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>sample</title>
    <script defer src="{% static 'app.js' %}"></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

app.js is hole React SPA application(build by webpack)

I don't have enough time to investigate this now.
(I freezed to old 3.7.0 version)
I'll look into it when I get some time.

It would be very happy if you could find out anything.

Thank you.

@tim-schilling
Copy link
Contributor

@heavenshell when investigating it, keep in mind the toolbar does this patching to detect when an ajax request is made.

@skamansam
Copy link

Just to show support, I am also having this issue with 3.8.1. It is happening on DRF views and drf-yasg (swagger/redoc) views - basically all the django html views that show the toolbar.

My settings are:

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.history.HistoryPanel',
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
    'debug_toolbar.panels.profiling.ProfilingPanel',
]
MIDDLEWARE = MIDDLEWARE + [
    "debug_toolbar.middleware.DebugToolbarMiddleware",
]
INSTALLED_APPS = DEFAULT_APPS + ['debug_toolbar']

@tim-schilling
Copy link
Contributor

@skamansam it should be possible over set the SHOW_TOOLBAR_CALLBACK setting to a view that can determine if the view should be instrumented or not based on your own application's needs.

@heavenshell
Copy link
Author

FYI
When I remove 'debug_toolbar.panels.history.HistoryPanel', from DEBUG_TOOLBAR_PANELS,
This issue does not raised(django-debug-toolbar==4.2.0)

@tim-schilling
Copy link
Contributor

@heavenshell I'm going to close this until there's a reproducible example.

@tim-schilling tim-schilling closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
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

No branches or pull requests

4 participants