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

Not being notified when N+1 is detected in turbo frame or turbo stream #724

Open
tpaulshippy opened this issue Nov 2, 2024 · 5 comments · May be fixed by #725
Open

Not being notified when N+1 is detected in turbo frame or turbo stream #724

tpaulshippy opened this issue Nov 2, 2024 · 5 comments · May be fixed by #725

Comments

@tpaulshippy
Copy link

tpaulshippy commented Nov 2, 2024

I'm not sure if this belongs as an issue in https://github.com/flyerhzm/uniform_notifier or here.

Our team makes heavy use of Turbo in our applications. We have been dealing with a lot of N+1 issues that Sentry is able to detect but Bullet is not always alerting us to them at development time. One of the reasons we have noticed is that Bullet will not notify us when there is an issue with a request that is either streamed back via turbo stream or just on a navigation that is shown in a turbo frame.

I have created a branch in my playground app to illustrate the issue.
Despite having the following in my development.rb --

  config.after_initialize do
    Bullet.enable        = true
    Bullet.alert         = true
    Bullet.bullet_logger = true
    Bullet.console       = true
    Bullet.rails_logger  = true
    Bullet.add_footer    = true
  end

I am not seeing any indication that there is an issue unless I examine my server logs in my terminal.

This commit shows the issue with streams.
And this commit shows the issue with frames.

Here is a screen recording of the issue --

bullet-turbo-issue-smaller.mov

The only "workaround" for this is:

    Bullet.raise         = true
@flyerhzm
Copy link
Owner

flyerhzm commented Nov 3, 2024

@tpaulshippy bullet frontend notification only works in html response, turbo doesn't provide any means to execute JS

@tpaulshippy
Copy link
Author

tpaulshippy commented Nov 3, 2024

The funny thing about that statement is that turbo is written in javascript. 😁

But yeah I get it that there is not an easy solution here. Even if it was just intercepting the request and returning "Content missing" like rails does with a lot of turbo issues, that would be better.

I'm not sure why bullet couldn't stream back the warning through turbo. Or provide a turbo client side event hook that detects something in the response and does the alert. I'll work on something.

@flyerhzm
Copy link
Owner

flyerhzm commented Nov 3, 2024

@tpaulshippy bullet injects the html response in lib/bullet/rack.rb, you can add the turbo stream support here.

@tpaulshippy
Copy link
Author

Great. I'll start there. Thanks.

@tpaulshippy
Copy link
Author

tpaulshippy commented Nov 3, 2024

Code in this branch seems to be working. I'll try to work on a PR with tests at some point.

Decided to just timebox it and got it done.

@tpaulshippy tpaulshippy linked a pull request Nov 3, 2024 that will close this issue
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 a pull request may close this issue.

2 participants