Skip to content

[WebProfilerBundle] Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed #41346

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

Merged
merged 1 commit into from
May 21, 2021

Conversation

weaverryan
Copy link
Member

@weaverryan weaverryan commented May 20, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #41305
License MIT
Doc PR Not needed

This bug was introduced in #41168.

Best viewed with: https://github.com/symfony/symfony/pull/41346/files?w=1 - we could also remove the new indentation in exception.js.

In that PR, we innocently don't reload Sfjs if it doesn't exist. However, on an error page, that template ALSO adds an Sfjs, and that Sfjs is smaller - containing only a subset of the Sfjs functions. This is tricky, but this PR fixes it.

Here are the various situations:

  1. I hit an exception page. The Sfjs from exception.js is loaded first. This adds the smaller Sfjs. Then the base_js.html.twig version is hit. Because Sfjs is missing the loadToolbar() method, that code DOES run again to reinitialize it.

  2. I am on a normal page, then travel to an exception page with Turbo. In this case, the original Sfjs from base_js.html.twig was processed. Then, on the exception page, the Sfjs from exception.js is ignored, as is the 2nd execution of base_js.html.twig.

Overall, the JS could use some work for supporting things like Turbo (e.g. DOMContentLoaded doesn't work with Turbo, so the exception page JS is broken). But I wanted to focus on fixing the bug in this PR.

As a reminder, #41168 (avoiding overriding Sfjs) was done to help with the AJAX toolbar and Turbo - it's explained in point (1) on #41168.

Cheers!

@weaverryan weaverryan requested a review from yceruto as a code owner May 20, 2021 19:11
@derrabus derrabus added this to the 4.4 milestone May 20, 2021
@carsonbot carsonbot changed the title Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed [WebProfilerBundle] Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed May 20, 2021
@derrabus derrabus changed the base branch from 5.4 to 4.4 May 20, 2021 21:26
@derrabus derrabus closed this May 20, 2021
@derrabus derrabus reopened this May 20, 2021
@mhujer
Copy link
Contributor

mhujer commented May 21, 2021

@weaverryan I can confirm that this fixes #41305 on 5.2.8 👍

@nicolas-grekas
Copy link
Member

Thank you @weaverryan.

@nicolas-grekas nicolas-grekas merged commit a76cdec into symfony:4.4 May 21, 2021
@weaverryan weaverryan deleted the fix-sfjs-error branch May 27, 2021 16:58
This was referenced May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug toolbar not showing on Symfony exception pages
5 participants