`to_json` times out
ottz0 opened this issue · comments
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
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
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).
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 }}
Thanks! Can you share the blueprint for the marketplace
collection?
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
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).
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
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.
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
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.
Good find!
This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.