This message was deleted.
# helpdesk
s
This message was deleted.
a
cc @polite-kilobyte-67570
šŸ™ 1
p
Hi @narrow-action-3234, does this happen when the browser tab/window is being closed or also when the component unmounts without navigation/browser being closed?
n
Hi @polite-kilobyte-67570, it happens when for example moving from the the call page where I’ve implemented Livekit to another page by calling the
history.push('/')
function … my workaround is thinking this is a SPA issue, maybe, is also after this calling
window_.location.reload_();
function so I reload the page that I’m redirecting to so I make sure the call connection is closed but also the camera is turning off.
a
@narrow-action-3234 you may have meant to tag Lukas not Luis ;)
n
oh, ya
mistake :))
šŸ˜… 2
šŸ˜…
p
The navigation within your SPA occurs entirely client-side right? so there’s no actual browser page (un)loading? Does it work if you call
Copy code
room.disconnect()
directly before doing the SPA navigation?
n
@red-country-59682 Yes, only client. My example is wrong.. sorry. The issue is when I’m not performing the redirect like the user pressing on a button in the page and the actual issue is when he presses the browsers back button, not one from the application where i can control the redirect to happen after disconnecting from the call.
So if I do this for example:
Copy code
await room?.disconnect();
history.push('/');
I disconnected from the call before redirecting but if the user presses the browser back button and as a consequence the component is unmounting Likekit does not detect this and disconnect me from the call and if trying on onmount effect to manually disconnect the user is not working
Copy code
useEffect(() => {
        return () => {
            (async () => {
                await roomCall?.disconnect();           
        };
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);
p
thanks for clarifying. We do a couple of things to try and disconnect automatically when a component unmounts or when a page gets unloaded. Disconnection might take a tiny bit longer on slower connections, but generally it should be more or less instant. To your manual disconnect call, the example you posted seems wrong (there’s a couple of parenthesis missing), but maybe that’s just a copy-past error? have you tried a simpler version with
Copy code
useEffect(() => {
  return () => roomCall.disconnect();
});
also, if your
roomCall
is potentially undefined, are you sure you are actually calling disconnect? It’s strange that it doesn’t work out of the box for you though. Could you spin up a minimal reproduction repository? that would be helpful in debugging this.
n
I see, in fact your right @polite-kilobyte-67570 with
roomCall
being
undefined
so that’s why is not working … but the interesting part comes if I console.log(roomCall) the values of it comes like this:
Copy code
useEffect(() => {
        return () => {
            console.log({roomCall})        
        };
        // eslint-disable-next-line react-hooks/exhaustive-deps
    }, [roomCall]);
Initial render:
Copy code
{roomCall: undefined}
Second render since is a dependency of `useEffect`:
Copy code
{roomCall: Room}
On unmount:
Copy code
{roomCall: undefined}
Not sure why is
undefined
to be honest on unmount, maybe because
Livekit
detects that the component unmounts and calls the
disconnect
function? But the issue is interesting because even though let’s assume LiveKit disconnected me from the call I still can see I’m connected if I’m not
manually refreshing
the page and if i’m going back again in the call and repeat the process w/o refresh the call I can see me multiple times inside the call
p
I think this behaviour might be specific to your implementation but it’s hard to say without more code context. If you can spin up a minimal reproduction example that showcases the issue, I’m happy to take a look!
n
Hi @polite-kilobyte-67570
Sorry for late response
r
Hi @narrow-action-3234, I guess youā€˜re still talking to Lukas? šŸ˜„
n
Yes :)))
you are the first appearing in the mention list :)))
and by mistake I tend to choose you
:))
r
Haha, never mind 🫔
n
@polite-kilobyte-67570 the ā€œbugā€ with disconnecting and reconnecting to the room I reproduced it also with the example you guys are hosting over here:
Copy code
<https://example.livekit.io/#/>
I connect then press back button … connect again … press again the back button … connect again and 2 times i connected and disconnected still appear to be connected.
w/o refreshing the page the user still remains connected to the call until he forces a refresh of the page when the disconnect really happens.
p
thanks for the update! I will post this insight also on the GH issue you opened and try to reproduce with the react example!
n
Ok, nice. Hope this context helps the debugging process
What I saw for example on Google meet is if you press back from the browser they produce a reload of the page with also the redirect happen so maybe they don't have this issue?
p
a new version of react-components is released that fixes this issue!
šŸš€ 1
n
Nicee
Saw I think yesterday the pr with the fix, thank you very much @polite-kilobyte-67570