eliom
eliom copied to clipboard
Odd behavior of React events
I added a simple React event to my super basic eliom-distillery generated server (https://github.com/bruce-ricard/miscellaneous/blob/serverevent/eliom-client-file/test/test.eliom).
The added code is from lines 30 to 50. I created a react event which sends a new integer to the channel every second (line 35). I add a listener to this even (line 48) which just prints what it finds on the channel.
If you run the code with run test.byte
, you can see in the logs that the React code works well: it sends the data to the channel, it is received and printed. Now, hit the server curl localhost:8080
, and suddenly the consumer of the channel stops printing.
I am not sure if this is a bug or if there's something I don't understand about how this works. I tried with React and Lwt_react, they both have the same behavior.
It is possible that the connections from other clients trigger a garbage collection and that the reactive values are garbage-collected. You have to keep a reference to them somewhere.