Skip to content

Max Call Stack error with large template #57066

Closed

Description

@Nabelops

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

When upgrading from v17 to v18, our components with large svg templates with template bindings failed to load with a RangeError: Maximum call stack size exceeded. We were able to get rid of this error by reducing the size of the template. I have created a stackblitz that shows this the same template (a random svg seating chart I found online) works on v17 and not on v18.

Working v17
https://stackblitz.com/edit/angular-17-starter-project-xnu5ts?file=src%2Fmain.ts

The link to the minimal reproduction of the bug will be the identical setup but with v18.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-by85ky?file=src%2Fmain.ts

Please provide the exception or error you saw

RangeError: Maximum call stack size exceeded
    at executeTemplate (core.mjs:11264:5)
    at renderView (core.mjs:12426:7)
    at renderComponent (core.mjs:12372:3)
    at renderChildComponents (core.mjs:12472:5)
    at renderView (core.mjs:12454:7)
    at createAndRenderEmbeddedLView (core.mjs:12493:5)
    at TemplateRef2.createEmbeddedViewImpl (core.mjs:13419:27)
    at ViewContainerRef2.createEmbeddedView (core.mjs:16880:33)

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

Activity

  1. JoostK commented on Jul 21, 2024

    @JoostK
    Member

    The v18 StackBlitz works fine for me, using Chrome in StackBlitz.

  2. Nabelops commented on Jul 21, 2024

    @Nabelops
    Author

    The v18 StackBlitz works fine for me, using Chrome in StackBlitz.

    Yeah it is working for me too now. I will work on a better reproduction.

  3. Nabelops commented on Jul 21, 2024

    @Nabelops
    Author
  4. JoostK commented on Jul 21, 2024

    @JoostK
    Member

    Interesting, that overflows TS's stack during emit.

    You can reduce the stack depth by inserting <ng-container></ng-container> halfway the SVG as a workaround.

  5. added
    area: compiler
    P3
    on Jul 21, 2024
  6. added this to the Backlog milestone on Jul 21, 2024
  7. Nabelops commented on Jul 21, 2024

    @Nabelops
    Author

    Interesting, that overflows TS's stack during emit.

    You can reduce the stack depth by inserting <ng-container></ng-container> halfway the SVG as a workaround.

    Interesting, if I remember correctly, ng container used to not work in svgs

  8. Nabelops commented on Jul 21, 2024

    @Nabelops
    Author

    Interesting, that overflows TS's stack during emit.

    You can reduce the stack depth by inserting <ng-container></ng-container> halfway the SVG as a workaround.

    Just reporting back that this does indeed fix the issue we had. Random <ng-container></ng-container> in the svg. Though in our case, it took more than one.

  9. JoostK commented on Jul 21, 2024

    @JoostK
    Member

    I opened #57069 to limit the chaining depth. The diff is small so you may be able to patch it in locally to see if it resolves the issue without needing the ng-container elements.

  10. added a commit that references this issue on Jul 22, 2024
    a5d053d
  11. added a commit that references this issue on Jul 22, 2024
    4639450
  12. added a commit that references this issue on Jul 22, 2024
    08c5977
  13. added a commit that references this issue on Jul 29, 2024
    809eb9a
  14. angular-automatic-lock-bot commented on Aug 22, 2024

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  15. locked and limited conversation to collaborators on Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: compilerstate: has PR

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions