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

to_json times out #10257

Open
ottz0 opened this issue Jun 4, 2024 · 12 comments
Open

to_json times out #10257

ottz0 opened this issue Jun 4, 2024 · 12 comments

Comments

@ottz0
Copy link

ottz0 commented Jun 4, 2024

Bug description

Just upgraded to v5 and it appears that the json that was valid, now appears no to be valid or is timing out my browser.

How to reproduce

{{ servers | to_json | entities }} now does not render due to upgrade

Logs

Maximum execution time of 30 seconds exceeded.

SyntaxError: Unexpected end of JSON input

Environment

Laravel Version: 10.48.12
PHP Version: 8.3.4
Composer Version: 2.7.2
Environment: local
Debug Mode: ENABLED
URL: medusa.test
Maintenance Mode: OFF

Addons: 7
Sites: 1
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.6.2 PRO

Installation

Existing Laravel app

Additional details

No response

@ottz0 ottz0 closed this as completed Jun 4, 2024
@ottz0
Copy link
Author

ottz0 commented Jun 4, 2024

Needs further investigation. tried parsing another object and that worked. Upgrade does not like the JSON output which worked fine before upgrading....SyntaxError: Unexpected end of JSON input

@ottz0 ottz0 reopened this Jun 4, 2024
@ottz0
Copy link
Author

ottz0 commented Jun 4, 2024

I've dumped a collection it had references to other members in the collection such as next, previous, children and parent. Is the json trying to warp those references and getting into a loop and making it timeout?

`Maximum execution time of 30 seconds exceeded

{{ servers | to_json | entities }}`

Screenshot 2024-06-04 at 3 15 32 PM

@duncanmcclean duncanmcclean changed the title V5 - Json times out to_json times out Jun 4, 2024
@duncanmcclean
Copy link
Member

What is the servers field? Can you share the field config from the blueprint's YAML file?

Also, are you able to share the data for the servers field that's causing it to error? (you can find that in the entry's markdown file).

@ottz0
Copy link
Author

ottz0 commented Jun 5, 2024

It's not in a Yaml file, I'm looping through a nav:collection.

This works

{{ servers = {{ nav:collection:marketplace from="/marketplace/{segment_2}" }} }}
{{ servers }}
    {{ title }}
{{ /servers }}

This also works

{{ nav:collection:marketplace from="/marketplace/{segment_2}" }}
    <div class="column is-6-tablet is-4-desktop">
        {{ title }}
    </div> 
{{ /nav:collection:marketplace }}

This works with the modifier

{{ nav:collection:marketplace from="/marketplace/{segment_2}" }}
    <div class="column is-6-tablet is-4-desktop">
        {{ title | to_json | entities }}
    </div> 
{{ /nav:collection:marketplace }}

This used to work but now now has errors: Maximum execution time of 30 seconds exceeded. SyntaxError: Unexpected end of JSON input.

 {{ servers = {{ nav:collection:marketplace from="/marketplace/{segment_2}" }} }}
 {{ servers | to_json | entities }}

@duncanmcclean
Copy link
Member

Thanks! Can you share the blueprint for the marketplace collection?

@ottz0
Copy link
Author

ottz0 commented Jun 5, 2024

Marketplace blueprint

title: 'Marketplace Child'
tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: product_type
            field:
              display: 'Product Type'
              type: button_group
              icon: button_group
              listable: hidden
              instructions_position: above
              visibility: visible
              options:
                dedicated-server: 'Dedicated Server'
                cloud-server: 'Cloud Server'
                vdc: VDC
                colocation: Colocation
          -
            handle: type_dedicated_servers
            field:
              options:
                enterprise: Enterprise
                blaze: Blaze
                gpu: GPU
              display: 'Dedicated Servers'
              type: button_group
              icon: button_group
              listable: hidden
              instructions_position: above
              visibility: visible
              validate:
                - sometimes
                - required
              if:
                product_type: 'equals dedicated-server'
          -
            handle: type_cloud_servers
            field:
              options:
                essentials: Essentials
                storage: Storage
              display: 'Cloud Servers'
              type: button_group
              icon: button_group
              listable: hidden
              instructions_position: above
              visibility: visible
              validate:
                - sometimes
                - required
              if:
                product_type: 'equals cloud-server'
          -
            handle: title
            field:
              type: text
              validate:
                - required
          -
            handle: icon_image
            field:
              mode: list
              container: assets
              restrict: false
              allow_uploads: true
              show_filename: true
              display: 'Icon Image'
              type: assets
              icon: assets
              listable: hidden
              instructions_position: above
              visibility: visible
              max_files: 1
              folder: logos
          -
            handle: pricing
            field:
              display: Pricing
              type: section
              icon: section
              listable: hidden
              instructions_position: above
              visibility: visible
          -
            handle: price
            field:
              input_type: text
              antlers: false
              display: Price
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
          -
            handle: button
            field:
              display: Button
              type: section
              icon: section
              listable: hidden
              instructions_position: above
              visibility: visible
          -
            handle: button_label
            field:
              input_type: text
              antlers: false
              display: 'Button Label'
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
          -
            handle: button_url
            field:
              display: 'Button URL'
              type: link
              icon: link
              listable: hidden
              instructions_position: above
              visibility: visible
  sidebar:
    display: Sidebar
    sections:
      -
        fields:
          -
            handle: slug
            field:
              type: slug
              localizable: true
          -
            handle: parent
            field:
              type: entries
              collections:
                - marketplace
              max_items: 1
              listable: false
              localizable: true
          -
            handle: template
            field:
              hide_partials: true
              blueprint: false
              display: Template
              type: template
              icon: template
              listable: hidden
              instructions_position: above
              visibility: visible
  config:
    display: Config
    sections:
      -
        fields:
          -
            handle: gpu_setting
            field:
              display: GPU
              type: list
              icon: list
              listable: hidden
              instructions_position: above
              visibility: visible
              if:
                type_dedicated_servers: 'equals gpu'
          -
            handle: processor_type
            field:
              display: Processor
              type: list
              icon: list
              listable: hidden
              instructions_position: above
              visibility: visible
              unless:
                product_type: 'equals colocation'
          -
            handle: memory
            field:
              input_type: text
              antlers: false
              display: Memory
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              unless:
                product_type: 'equals colocation'
          -
            handle: storage
            field:
              display: Storage
              type: list
              icon: list
              listable: hidden
              instructions_position: above
              visibility: visible
              unless:
                product_type: 'equals colocation'
          -
            handle: network_data
            field:
              input_type: text
              antlers: false
              display: Data/Network
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
          -
            handle: ip_s
            field:
              input_type: text
              antlers: false
              display: "Ip's"
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              if_any:
                product_type: 'equals colocation'
          -
            handle: amps
            field:
              input_type: text
              antlers: false
              display: Amps
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              if:
                product_type: 'equals colocation'
          -
            handle: pdu_s
            field:
              input_type: text
              antlers: false
              display: "Pdu's"
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              if:
                product_type: 'equals colocation'
          -
            handle: access
            field:
              input_type: text
              antlers: false
              display: Access
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              if:
                product_type: 'equals colocation'
          -
            handle: additional_ip_s
            field:
              input_type: text
              antlers: false
              display: "Additional IP's"
              type: text
              icon: text
              listable: hidden
              instructions_position: above
              visibility: visible
              if:
                product_type: 'equals vdc'
  related:
    display: Related
    sections:
      -
        display: 'New Section'
        fields:
          -
            handle: related_links
            field:
              collapse: false
              previews: true
              fullscreen: true
              sets:
                new_set_group:
                  display: 'New Set Group'
                  instructions: null
                  icon: null
                  sets:
                    new_set:
                      display: 'New Set'
                      instructions: null
                      icon: null
                      fields:
                        -
                          handle: label
                          field:
                            input_type: text
                            antlers: false
                            type: text
                            display: Label
                            icon: text
                            listable: hidden
                            instructions_position: above
                            visibility: visible
                            replicator_preview: true
                            hide_display: false
                        -
                          handle: link
                          field:
                            type: link
                            display: Link
                            icon: link
                            listable: hidden
                            instructions_position: above
                            visibility: visible
                            replicator_preview: true
                            hide_display: false
              type: replicator
              display: 'Related Links'
              icon: replicator
              listable: hidden
              instructions_position: above
              visibility: visible
              replicator_preview: true
              hide_display: false
      -
        display: 'Related Articles'
        fields:
          -
            handle: entries_field
            field:
              mode: default
              create: true
              type: entries
              display: Entries
              icon: entries
              listable: hidden
              instructions_position: above
              visibility: visible
              replicator_preview: true
              hide_display: false

@jelleroorda
Copy link
Contributor

Perhaps you have a circular reference through the related entries?

I.e. page 1 points to page 2, page 2 points to page 1 (or maybe 1 > 2 > 3 > 1). That would end up with an infinite loop when trying to serialize it to json (hence timing out).

@ottz0
Copy link
Author

ottz0 commented Jun 17, 2024

Perhaps you have a circular reference through the related entries?

I.e. page 1 points to page 2, page 2 points to page 1 (or maybe 1 > 2 > 3 > 1). That would end up with an infinite loop when trying to serialize it to json (hence timing out).

I thinks that's whats happening. It's weird that this was working right before I went to upgrade to V5

@duncanmcclean
Copy link
Member

Let's try and rule out it being an infinite loop / circular reference loop...

Can you try commenting out the various Entries fields from the blueprint, and see if that fixes the issue? If it does, can you try uncommenting the fields one-by-one to see which one is causing it.

@jasonvarga
Copy link
Member

In v5 we serialize entries properly. Perhaps in v4 you had an empty object somewhere so you didn't run into the recursion. See #9672

@ottz0
Copy link
Author

ottz0 commented Jun 18, 2024

Found it...this was relating to my post a few years ago ##5866. Same thing happening. I had a Related Articles repeater with entries. Max items was blank causing it to loop. Setting Max items in Appearance & Behaviour to 1 stopped this.

Screenshot 2024-06-18 at 1 48 07 PM
Screenshot 2024-06-18 at 1 50 40 PM

@duncanmcclean
Copy link
Member

Good find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants