Skip to content

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

Closed
@tbmatuka

Description

@tbmatuka

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions