-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
amp-bind: Expression complexity limit reached #11434
Comments
@Gigliocom - Thanks for reaching out! Could you provide detailed steps on how to reproduce the issue (and what this issue is). I did not see any errors on the link above. |
Hi, In console.log appear this: |
/to @choumx |
Hi Giglio.com, thanks for your feedback. The expression complexity limit is intended to keep pages using One way you can simplify your page expressions (and speed up the page itself!) is to reduce the number of variables. Specifically, I think you can remove the Instead of showing/hiding 4 different <amp-state id="product">
{
"027": {
"image1": "images/027/1.jpg",
"image2": "images/027/2.jpg",
...
}
}
</amp-state>
<amp-carousel>
<amp-img [src]="product[selectedColor].image1"></amp-img>
<amp-img [src]="product[selectedColor].image2"></amp-img>
</amp-carousel> Hope that helps! |
Hi @choumx, There is an another way to execute more than 50 expressions? |
Ah, yes. We're planning to support more dynamic slide content in
Not at the moment, though we may revisit this if it's a common problem -- I'll use this issue to track. Intermediary variables would also help reduce duplication of expression fragments in your case (#8397). Sorry that you're have difficulties with |
This issue doesn't have a category which makes it harder for us to keep track of it. @choumx Please add an appropriate category. |
Definitely need to increase the limit. I'm creating a page with personalised products. Customer have options to choose designs, colours, pictures, fonts and enter custom text. We are using amp-bind to build up a preview link. 50 operands are definitely not enough. Alternatively, is there any ways I can encode the state json object and pass to the server as an parameter? |
@ivanliu8 Can you share a sample page with expressions that exceed this limit? |
may i know how do you calculate the operands ? such as AstNodeType.NOT is equivalent to how many operands , AstNodeType.TERNARY is equivalent to how many operands, a reference to the source code would be much appreciated. Thx in advanced ! @choumx |
"Operand" is loosely defined here. 😄 It's technically the number of nodes in the abstract syntax tree of the expression. I'd really appreciate any example pages that exceed the operand limit. This way we can thoughtfully support your use cases without necessarily changing the performance characteristics of |
a work around trick would be: based on the documentation, a simple demo as below:
code:
|
HI , I am facing the same issue, I try to pass say 10 or more state parameters in url, but it is failing |
@choumx Hi we are using amp-state to bind the values to the url. |
Can you share the markup for this element? |
Hi Choumx, This is what I am trying to do,
|
Where is It looks like most of these variables are from |
I'm running up against this issue as well. Currently sitting at 6 over the 50 limit. I'm building a filterable inventory list that gets its JSON data from our ERP systems API. I'm trying to find ways to reduce the operands in my on change event but not seeing it yet - still working on it though. My second amp-list (Machine Make) is the one that is maxing out on me. I'm trying to build the list so that it filters on each drop down selection, currently I have it working with the first two but when I add the model filter in that determines what to populate the third dropdown with it maxes out on me.
|
@Makac Thanks for the feature request. We could do this by adding a new URL replacement variable that reads from
@craigscott29 Thanks for posting your use case. I think it looks reasonable. Since people are hitting the "50 operand" limit much more often than the "2000 binding" limit, I'm going to see if we can shift this balance to something like 100 operands and 1000 bindings and still retain (roughly) the same performance bounds. Thanks for your patience everyone. |
@choumx any chance of the operand increase having a quick turn around? The president of the company I work for wants the inventory list live in the next 2 weeks haha. |
@craigscott29 Given our weekly release cycle, unlikely. :( In the meantime, you can try performing some of the filtering server-side. I.e. change the second amp-list's endpoint via a |
It won't do anything automatically. That sample shows server-side filtering/sorting -- the idea is to read the query parameters on the server and then perform the sorting on the server. OTOH, your current code performs filtering/sorting on the client. This is fine for simple examples but can hit complexity limits as you've seen. :) Generally, AMP strives to "solve problems at the right layer", so we believe that more complex business logic should be done on the server, not the client. Of course there are shades of gray in between -- sometimes it's nice to not perform a network request when changing a filter. For your case, since you're performing an network request anyways, doing the filtering on the server should work. Hope that makes sense! |
I may be thinking about this incorrectly, but I think the server-side is where my issue may be. The data I'm retrieving doesn't exist on the same server as the site. I'm scraping it from our ERP systems API which is data output only. Essentially, I can retrieve my block of data in one pull (which is all I'd want to do because it's a slow system) and can't query against the server itself. I'll maybe try setting up a service to pull the data down daily to the web server. |
Ah, I see. Yea, having a flexible server is very useful when developing with AMP in general. |
Hi @choumx I'm trying to render an expression with amp-list and facing the same issue. This is for calculating the price of merchandise with different additions.
Is there any workaround? |
To be frank, we are not really sure how to do the counting for the bindings, currently we got 2 concerns about reducing the "2000" bindings limit down to "1000" :
While for the decision of increasing the operands from 50 to 100, we are quite happy with it, but it may lead to another question. FYI, due to the "less logic restriction" of |
@leonalicious Thanks for the feedback.
Sorry about that bug again.
This is a good point and may come up more often once amp-list's infinite scroll feature is released. I think it's reasonable to allow the binding limit to increase for those use cases. Eventually we may need to implement a more robust performance solution. |
@gtonysam @Makac We recently added the See the URL variable substitutions docs for more detail. |
Update: In the last 7 days, there have been < 50 instances where an AMP page exceeds 1000 bindings (including runtime changes e.g. "view more" button) across very few domains. I think we can safely rebalance the complexity limit to 100 operands and 1000 bindings, which should help unblock many use cases. I'll open another issue to address the "view more" and infinite scroll use case. |
Please see #15519 for discussion on binding limits vis-a-vis infinite scroll/view more. |
Fixed by #15517. |
I'd like to execute this assignment, but I get this error: amp-bind: Expression eval failed. Expression size (104) exceeds max (100). Please reduce number of operands. I made my response so nested, because I wanted support for global variables in an amp-list template where I also use the same endpoint. |
Can you post an example of this large expression please? |
But I changed my response and removed the my_response[0]. part and it works now. |
What's the issue?
We need to perform over 50 expressions in unique AMP page, how can we do it?
How do we reproduce the issue?
Below a demo AMP product page with the errors.
https://www.giglio.com/borse-donna_borsa-mano-borsa-petite-2-jours-piccola-con-barra-metallica-logo-inciso-fendi-8bh2533wl.html?cSel=027&AAMMPP
What browsers are affected?
All browsers
Which AMP version is affected?
V0
The text was updated successfully, but these errors were encountered: