From c45a237b4706b135266155c79bdd6eb58108e6e2 Mon Sep 17 00:00:00 2001 From: Ivan Katanovic Date: Mon, 21 Oct 2024 15:24:58 +0200 Subject: [PATCH] Delete json_tag from child components as it could cause RecursionError --- django_unicorn/components/unicorn_template_response.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/django_unicorn/components/unicorn_template_response.py b/django_unicorn/components/unicorn_template_response.py index eb9f3014..608dae29 100644 --- a/django_unicorn/components/unicorn_template_response.py +++ b/django_unicorn/components/unicorn_template_response.py @@ -247,6 +247,11 @@ def render(self): for child in descendant.children: init_script = f"{init_script} {child._init_script}" json_tags.append(child._json_tag) + # We need to delete this property here as it can cause RecursionError + # when pickling child component. Tag element has previous_sibling + # and next_sibling which would also be pickled and if they are big, + # cause RecursionError + del child._json_tag descendants.append(child) script_tag = soup.new_tag("script")