avo-hq/avo

Code reloading causes ever-increasing redundant reloading of assets

Open

#1,975 opened on Oct 12, 2023

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Ruby (308 forks)user submission
AnnoyanceHelp wanted

Repository metrics

Stars
 (1,778 stars)
PR merge metrics
 (Avg merge 1d 6h) (67 merged PRs in 30d)

Description

Describe the bug

When I make a change that causes code reloading (I've tried this with the Avo initializer and with an Avo resource and both induce the issue), subsequent page views will attempt to load several Avo asset bundles multiple times, with the number of times increasing every time code is reloaded. E.G.

Edit initializer, load a resource page:

13:40:40 web.1          | Started GET "/avo-assets/avo.base.css" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-assets/avo.base.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-assets/logomark.png" for 127.0.0.1 at 2023-10-12 13:40:40 -0700
13:40:40 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:40:40 -0700

Edit initializer again, re-load resource page:

13:41:26 web.1          | Started GET "/avo-assets/avo.base.css" for 127.0.0.1 at 2023-10-12 13:41:26 -0700
13:41:26 web.1          | Started GET "/avo-assets/avo.base.js" for 127.0.0.1 at 2023-10-12 13:41:26 -0700
13:41:27 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-assets/logomark.png" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/admin/resources/users/22/comments?turbo_frame=has_many_field_show_comments_ons&view=show" for 127.0.0.1 at 2023-10-12 13:41:27 -0700
13:41:27 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:41:27 -0700

Edit resource, re-load resource page:

13:42:14 web.1          | Started GET "/avo-assets/avo.base.css" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-assets/avo.base.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-dashboards-assets/avo_dashboards.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-filters-assets/avo_filters.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/admin/resources/users/22/comments?turbo_frame=has_many_field_show_comments_ons&view=show" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-assets/logomark.png" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700
13:42:14 web.1          | Started GET "/avo-pro-assets/avo_pro.js" for 127.0.0.1 at 2023-10-12 13:42:14 -0700

The particular details vary a little bit depending on circumstances I haven't fully identified (e.g. in my test repo, modifying the initializer did not induce the issue, but modifying a resource did).

The impact of this is that page load times can become quite slow as one is iterating on code (6+ seconds on an M1 Max, vs. a clean-start load time of closer to 3 seconds). Restarting Rails is the only thing that "fixes" the issue -- albeit temporarily, AFAICT.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Set up https://github.com/MrJoy/avo-debug
  2. bin/dev
  3. Go to http://localhost:5000/admin/resources/users/1
  4. Note assets loaded in Rails output
  5. Modify app/avo/resources/user.rb
  6. Reload http://localhost:5000/admin/resources/users/1
  7. Note assets loaded in Rails output, which should include duplication
  8. Repeat steps 6-7, note even greater length

Expected behavior & Actual behavior

A given asset should only be loaded once per pageview

Models and resource files

System configuration

Avo version: 3.0.1.beta20

Rails version: 7.0.8

Ruby version: 3.2.2

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Additional context

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)

Contributor guide