Session partially and randomly lost using Ajax on Symfony 4

In a web page, I trigger many ajax calls. During some them, one variable of the session is lost. However, the user is not logged out, it is only the session variable that seems to be erased.

It’s happening like once in 250 times and I can’t reproduce it in development mode.

In one of them, I have an ajax request nested in the other, it is always the second that triggers an error (when it occurs) like such :

             $.ajax({
                type: "GET",
                url: "{{  path('route_1')  }}",
                async : true,
                success: function(mydata)
                {
                  $('#list').html(mydata['rend']).show();
                 
                  $.ajax({
                        type: "GET",
                        url: "{{  path('route_2')  }}", /* This one */
                        success: function(mydata)
                        {
                          $('#options').html(mydata['rend']).show();
                         }
                      }
                  });

                }
            });

Here is an example of the debug file in prod when it throws the error
(the date is ‘–‘ because of session[‘var’]->date(‘d’).’-‘.session[‘var’]->date(‘m’).’-‘.session[‘var’]->date(‘Y’)) :

[2024-05-30 15:17:44] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
[2024-05-30 15:33:58] request.INFO: Matched route "my_request". {"route":"my_request","route_parameters":{"_route":"my_request","_controller":"RouteToController\Controller::myFonction","_locale":"fr"},"request_uri":"https://siteweb.com/url","method":"GET"} []
[2024-05-30 15:33:58] security.DEBUG: Read existing security token from the session. {"key":"_security_main","token_class":"Symfony\Component\Security\Core\Authentication\Token\RememberMeToken"} []
[2024-05-30 15:33:59] security.DEBUG: User was reloaded from a user provider. {"provider":"Symfony\Bridge\Doctrine\Security\User\EntityUserProvider","username":"user"} []
[2024-05-30 15:33:59] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1} []
[2024-05-30 15:33:59] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\Security\LoginFormAuthentificatorAuthenticator"} []
[2024-05-30 15:33:59] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"main","authenticator":"App\Security\LoginFormAuthentificatorAuthenticator"} []
[2024-05-30 15:33:59] request.CRITICAL: Uncaught PHP Exception TwigErrorRuntimeError: "An exception has been thrown during the rendering of a template ("DateTime::__construct(): Failed to parse time string (--) at position 0 (-): Unexpected character")." at file.html.twig line 12 {"exception":"[object] (Twig\Error\RuntimeError(code: 0): An exception has been thrown during the rendering of a template ("DateTime::__construct(): Failed to parse time string (--) at position 0 (-): Unexpected character"). at file.html.twig:12, Exception(code: 0): DateTime::__construct(): Failed to parse time string (--) at position 0 (-): Unexpected character at /path/vendor/twig/twig/src/Extension/CoreExtension.php:546)"} []
[2024-05-30 15:33:59] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []

I first installed Redis, thinking it was a concurrent request problem and that it would solve it but it keeps happening. I tried to set async:false on some of the problematic ajax calls but didn’t do the trick either.
Finally, I tried to set 1s timeout but, guess what, didn’t work either.

This bug is very difficult to locate and the random fact really doesn’t help. If this is not a concurrent request problem then I can’t seem to find any viable solution…

Any help would be greatly appreciated, thank you !

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật