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

Rapid succession of comet-requests when using two Eliom_react.Down channels #796

Open
paurkedal opened this issue May 24, 2024 · 0 comments

Comments

@paurkedal
Copy link
Contributor

This issue is triggered by an in-application link for a service which uses two downwards react events (or signals). I am using eliom 10.4.1.

The issue can be reproduced as follows. The modified file is attached in case of issues with patching.

$ eliom-distillery -name eliom_react_down_issue -template client-server.basic
$ cd eliom_react_down_issue
$ patch -p0 <<EOF
--- eliom_react_down_issue.eliom.orig   2024-05-24 13:39:14.220081792 +0200
+++ eliom_react_down_issue.eliom        2024-05-24 13:59:58.116249385 +0200
@@ -21,9 +21,22 @@
   Eliom_service.create ~path:(Eliom_service.Path [])
     ~meth:(Eliom_service.Get Eliom_parameter.unit) ()
 
-let%client main_service = ~%main_service
+let%server make_counter start period =
+  let counter = ref start in
+  Lwt_react.E.from @@ fun () ->
+  Lwt_unix.sleep period |> Lwt.map (fun () -> incr counter; !counter)
+let%server counter1 = make_counter 0 2.0
+let%server counter2 = make_counter 0 3.0
 
-let%shared () =
+let%server counter_paragraph counter =
+  let client_node = [%client
+    Eliom_content.Html.R.txt
+      (React.S.map (Printf.sprintf "Counter: %d")
+        (React.S.hold 0 ~%(Eliom_react.Down.of_react counter)))
+  ] in
+  Eliom_content.Html.(F.p [C.node client_node])
+
+let%server () =
   App.register ~service:main_service (fun () () ->
     Lwt.return
       Eliom_content.Html.F.(
@@ -36,4 +49,9 @@
                       ~service:(Eliom_service.static_dir ())
                       ["css"; "eliom_react_down_issue.css"])
                  () ])
-          (body [h1 [txt "Welcome from Eliom's distillery!"]])))
+          (body [
+            h1 [txt "Welcome from Eliom's distillery!"];
+            a ~service:main_service [txt "Watch network activity and click me."] ();
+            counter_paragraph counter1;
+            counter_paragraph counter2;
+           ])))
EOF
$ make test.opt

Then open the browser with a debug panel, watch the "Network" activity tab (in Firefox), and press the link:

  • Before following the link, the __eliom_comet__ requests are issued at a normal rate of a few per second, and the page is updated as expected.
  • After following the link, there is a torrent of requests, and the page updates are more erratic.

eliom_react_down_issue.eliom.txt

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

No branches or pull requests

1 participant