NARCISO
04/30/2022, 12:57 AMsubscriptions.
I'm using NextJS and I use a hook in 2 different pages to setup the subscription that is basically this (copied from the nextjs-slack-clone official example):
...
useEffect(() => {
const messageListener = sb
.from<Message>("message")
.on("INSERT", (payload) => setTempNewMessage(payload.new))
.subscribe((event, e) => {
console.warn(`[Message] Listener ${event}`, messageListener);
if (e) {
console.error("[Message] Listener error", e);
}
});
console.error("STARTED LISTENING...", messageListener);
// Cleanup on unmount
return () => {
messageListener
.unsubscribe()
.receive("ok", () => console.error("!SUBSCRIPTION REMOVED!"));
};
}, []);
At the first page load, the subscription is all good and works perfectly.
But when I do router.push to the other page, it unsubscribe correctly but the new subscription starts CLOSED and even the RETRYING_AFTER_TIMEOUT does nothing.
Any ideas?Needle
04/30/2022, 12:57 AM/title command!
We have solved your problem?
Click the button below to archive it.Needle
04/30/2022, 12:58 AMgaryaustin
04/30/2022, 1:08 AMNeedle
04/30/2022, 1:08 AMNARCISO
04/30/2022, 1:09 AMNARCISO
04/30/2022, 1:09 AMNARCISO
04/30/2022, 1:13 AM2 messages are from the first page load.
The third message is the leave from the unsubscribe.
Then the fourth is the join from the new page and seeing the fifth message should be good.
But then the sixth closes the subscription for no reasonNARCISO
04/30/2022, 1:15 AMgaryaustin
04/30/2022, 1:16 AMNARCISO
04/30/2022, 1:16 AMgaryaustin
04/30/2022, 1:17 AMNARCISO
04/30/2022, 1:17 AMNARCISO
04/30/2022, 1:20 AMNARCISO
04/30/2022, 1:20 AMNARCISO
04/30/2022, 1:21 AMgaryaustin
04/30/2022, 1:21 AMNARCISO
04/30/2022, 1:22 AMNARCISO
04/30/2022, 1:23 AMsupabase.getSubscriptions() and see if I can for example see the subscription still not closed at all and wait? I don't know hahaNARCISO
04/30/2022, 1:25 AMgaryaustin
04/30/2022, 1:25 AMgaryaustin
04/30/2022, 1:26 AMgaryaustin
04/30/2022, 1:27 AMNARCISO
04/30/2022, 1:29 AMunsubscribe but it does not replace it. Actually, NextJS seems to close the subscription automatically.NARCISO
04/30/2022, 1:29 AMgaryaustin
04/30/2022, 1:31 AMNARCISO
04/30/2022, 1:31 AMgaryaustin
04/30/2022, 1:31 AMgaryaustin
04/30/2022, 1:33 AMNARCISO
04/30/2022, 1:34 AMgaryaustin
04/30/2022, 1:35 AMNARCISO
04/30/2022, 1:38 AMNARCISO
04/30/2022, 2:00 AMNARCISO
04/30/2022, 2:00 AMNeedle
04/30/2022, 2:05 AM