FoxxMD / context-mod

an event-based, reddit moderation bot built on top of snoowrap and written in typescript
https://contextmod.dev
MIT License
49 stars 11 forks source link

Replace websockets with polling #106

Open FoxxMD opened 1 year ago

FoxxMD commented 1 year ago

Previously replaced a large swatch of the initial websockets implementation with polling in #91

Currently websockets has become more cumbersome than it is beneficial:

It would be a better develop experience to just remove it entirely and replace it with another polling implementation.

OmgImAlexis commented 1 year ago

What about server sent events? Would remove the need to poll and you’d be able to handle it just like any other http request?

FoxxMD commented 1 year ago

SSEs are a possibility! With SSEs I'd still need to keep track of authenticated users that are currently connected which was the primary hassle with websockets.

So far I've found polling from the client has been more than sufficient. I replaced all websocket usage on the dashboard for real-time stats and was able to reduce traffic pretty significantly by tying it into the same idle timeouts log streaming is using.

The only place I haven't been able to entirely eliminate websockets is with reddit oauth on the config editor page -- I still need a way to communicate with the main window after oauth in completed from the popup and redirect occurs. I'll see if SSE might fit the bill for this.