fix: unreliable websocket functionality (#144)

* increases timeout

* refactor: reuse constants for redis db

* avoid closing connection on pong error

* fix: prevent electron from pausing timer executions

Our pings could be paused when our app is backgrounded.

* refactor: remove unnecessary refs

* fix: presence unreliable within same pod

It was broadcasting presence changes to other pods, but not notifying
clients connected to the same pod
This commit was merged in pull request #144.
This commit is contained in:
Arjun Patel
2026-04-12 10:00:11 -07:00
committed by GitHub
parent 4cb562e1ea
commit 2bc4ce7060
11 changed files with 64 additions and 35 deletions
+3 -9
View File
@@ -22,12 +22,6 @@ export function useChannel(channelId: string | null): UseChannelResult {
const [presence, setPresence] = useState<string[]>([]);
const [messages, setMessages] = useState<ChannelMessage[]>([]);
// Keep a ref to avoid re-subscribing when sendMessage changes
const clientRef = useRef(client);
const channelRef = useRef(channelId);
clientRef.current = client;
channelRef.current = channelId;
useEffect(() => {
if (!client || !channelId) {
setPresence([]);
@@ -80,11 +74,11 @@ export function useChannel(channelId: string | null): UseChannelResult {
const sendMessage = useCallback(
(payload: unknown) => {
if (clientRef.current && channelRef.current) {
clientRef.current.sendMessage(channelRef.current, payload);
if (client && channelId) {
client?.sendMessage(channelId, payload);
}
},
[],
[client, channelId],
);
return { presence, messages, sendMessage };
+1
View File
@@ -36,6 +36,7 @@ const createWindow = () => {
frame: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
backgroundThrottling: false,
},
});