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

[Engine Twig PHP] - pattern rendering broken in ^6.0.0 #1508

Open
eWert-Online opened this issue Jun 3, 2024 · 3 comments
Open

[Engine Twig PHP] - pattern rendering broken in ^6.0.0 #1508

eWert-Online opened this issue Jun 3, 2024 · 3 comments

Comments

@eWert-Online
Copy link
Contributor

I am using Pattern Lab Node v6.1.0 on Mac, with Node v20.11.1, using a Vanilla Edition.

Expected Behavior

Twig Templates get rendered without any error messages.

Actual Behavior

An PHP Error is thrown:

Undefined array key "data" in pattern_twig/node_modules/@basalt/twig-renderer/dist/server--async.php on line 115 when trying to render 00-meta/_foot.twig

Steps to Reproduce

Create a patternlab with a lot of patterns.
At some point, the number of patterns will exceed the max_post_size of the @basalt/twig-renderer.


I have analyzed the error a bit. It seems the body payload of the 00-meta/_foot.twig template is too large to be handled by the php @basalt/twig-renderer.
I have opened an issue in their repository as well and will try to submit a fix there. knapsack-cloud/twig-renderer#139

If the @basalt/twig-renderer will not accept the fix, is there a way to reduce the body payload in the _foot.twig template?

@mfranzke
Copy link
Contributor

mfranzke commented Jun 6, 2024

@eWert-Online thanks for reporting this. Could it be related to #1505 (and even also get solved by the solution provided in that other issue) ?

@eWert-Online
Copy link
Contributor Author

@mfranzke
Yes, it sounds like the same problem.
I wouldn't call downgrading a solution though. Its more a workaround until a real fix is available.

Do you see an option to reduce the size of the _footer template, where this error originates from?

@hadl
Copy link
Contributor

hadl commented Dec 18, 2024

Hi @eWert-Online, @mfranzke,

there are several reasons for this error.

  1. Basalt can't or won't handle more than 64K of requests for the Twig context. Due to the ReactPHP default setting
  2. The context for Twig will get bigger for every e.g. _data/*.json file.
  3. For every pattern there is a "link" key available (to be able to link between patterns).
    The more patterns you have, the bigger this object gets and it will be in the "context" too.
    My current project would currently use 22K for the "links"

Maybe it would make sense to make the linking feature configurable in pattern-lab?
Personally, i have never used this feature.

Or omit/delete the link data for rendering the _head and _foot?

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

3 participants