Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usePresence error - Uncaught (in promise) Error: Connection closed #1753

Closed
bookercodes opened this issue Apr 26, 2024 · 9 comments · Fixed by #1761
Closed

usePresence error - Uncaught (in promise) Error: Connection closed #1753

bookercodes opened this issue Apr 26, 2024 · 9 comments · Fixed by #1761
Assignees
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@bookercodes
Copy link

bookercodes commented Apr 26, 2024

When using usePresence, if I reload the page, I see the following error (with preserve log on)

ably.js:260 Uncaught (in promise) Error: Connection closed
    at _ErrorInfo.fromValues (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:260:34)
    at Object.closed (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:3697:27)
    at WebSocketTransport.close (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:3749:52)
    at _ConnectionManager.closeImpl (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:5113:42)
    at _ConnectionManager.requestState (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:4898:12)
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/ably/build/ably.js:4197:16)

I wonder if maybe ably-js is trying to send an event like "leave" but the connection is already closed? Possibly related to this LOC?

The code to reproduce is very simple:

import { usePresence } from "ably/react"

const WhosOnlineList = ({ channelName }) => {

  usePresence(channelName, { fullName: Math.random() })


  return null
}
export default WhosOnlineList

Why does this matter?

It might not. I don't think you can technically be "present" on a channel if the connection has closed, but I'd like to understand the error better in case I should be structuring my React component differently.

Thank you!

┆Issue is synchronized with this Jira Task by Unito

@nikitadubyk
Copy link

I have the exact same error, except I don't use the hook. The sample code I use is in the comment - #1565 (comment).

@VeskeR
Copy link
Contributor

VeskeR commented May 1, 2024

Hello @bookercodes , @nikitadubyk !

Thank you for reporting this and providing steps to reproduce. We're going to investigate this and get back with an update as soon as possible!

@VeskeR VeskeR added the bug Something isn't working. It's clear that this does need to be fixed. label May 2, 2024
@VeskeR
Copy link
Contributor

VeskeR commented May 2, 2024

Hey @bookercodes , @nikitadubyk !

I was able to reproduce the issue with the provided code sample. I'm currently looking into its cause.

@Elmosh
Copy link

Elmosh commented May 4, 2024

Same errors on page reload after updating to v2.

@bookercodes
Copy link
Author

Hello, I am working on a tutorial I'm aiming to publish this week and keep getting this error. Can it safely be ignored or am I doing something wrong?

@VeskeR
Copy link
Contributor

VeskeR commented May 9, 2024

Hey @bookercodes !
You are not doing anything wrong; this is an issue on the ably-js side. We're planning to release a fix for it this week.

In the meantime, since this error occurs on page reload and essentially tries to close a connection a second time after it's already been closed, you can safely ignore it for now. The only real downside is that these errors might appear in your log monitoring tools.

@VeskeR
Copy link
Contributor

VeskeR commented May 29, 2024

This has been fixed in #1761 and will be released in the next patch version for ably-js package.

@VeskeR
Copy link
Contributor

VeskeR commented Jun 3, 2024

Hey, the fix for this issue has been released in 2.1.0 release of ably-js.
Thank you for reporting this issue!

@VeskeR VeskeR closed this as completed Jun 3, 2024
@bookercodes
Copy link
Author

Great, thank you, I will update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging a pull request may close this issue.

4 participants