Open Spiral-Memory opened 5 months ago
Hey @devanshkansagra, this is the issue i was talking about, any help from your side will be greatly appreciated.
Yea sure I will be working on it
Let me also explain when we call the connect function defined in EmbeddedChatApi
in packages/api and how it works. In EmbeddedChat.js
in packages/react, within useEffect, we register a callback function into authListener. As soon as the authentication status changes (which occurs when notifyAuthListeners is called), a function will be triggered if it detects a user. In this function, we attempt to establish real-time communication using the connect function and set the user's details:
Description
If you try to integrate this
EmbeddedChat
package into a React application created usingcreate-react-app
, as soon as you log in, you will encounter a warning or error similar to this:A similar issue can also be found sometimes while in development, such as when Storybook hot reloads. Open the console log, and try to trigger actions like clicking on the page or typing something. You will notice a console error related to DDP:
The problem most likely lies in the connect function of the app in the
EmbeddedChatAPI
file. In the connect function, afterconnect({})
has been called, we call the resume function and pass the token. It seems like the connect function needs some time to establish the connection, and only after the connection is successfully established should other real-time DDP methods be called. If you comment out the section of code afterconnect({})
, things will start working fine. I have been seeing this issue for a long time, since January when I first started contributing, but I don't know how to fix it.Any help from other contributors would be really helpful.
Expected behavior
Real-time communication should be initiated only after a successful connection is made.
Update: As a temporary solution, Use "react": "^17.0.2" and "react-dom": "^17.0.2" in your project to avoid encountering this error during integration.