Skip to content

Exception thrown during twig rendering breaks encore tags on the error page #622

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

Closed
tbmatuka opened this issue Aug 5, 2019 · 1 comment

Comments

@tbmatuka
Copy link

tbmatuka commented Aug 5, 2019

Basically, when an exception gets thrown during rendering, EntrypointLookup doesn't get reset. If your page and the error page extend the same base template and use the same css/js, the error page won't get the tags that got rendered before the exception. I ran into this when trying to use an un-initialized paginator without a correct DB setup.

Simplest reproduction setup I can think of:

  1. Make the error pages extend your base template (create the templates/bundles/TwigBundle/Exception/error.html.twig file). Put the error in the body/content block.
  2. Render the base template in a controller.
  3. Add encore_entry_link_tags to your head section and add it again with an invalid entry name in the body/content block.
  4. Open the page in prod environment so that the error page renders.

I'm sure a lot of people have error pages set up like this, because it's a quick and easy way to make them not look horrible. A workaround for this is resetting the EntrypointLookup in an exception listener. If that's an OK solution for you guys as well, I can create a PR with that.

@Lyrkan
Copy link
Collaborator

Lyrkan commented Aug 6, 2019

@Lyrkan Lyrkan closed this as completed Aug 6, 2019
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

2 participants