Skip to content

Fix order of .on() and .connect() in chat example #7802

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

Closed

Conversation

gbhardwaj00
Copy link
Contributor

Summary

This PR fixes the order of method calls in the useChatRoom example. Previously, connection.connect() was called before connection.on('message', ...), which caused a subtle issue: the message handler (messageCallback) might be null when the first message interval ticks.

What Changed

  • Moved connection.on('message', ...) before connection.connect() in the example code.

@rickhanlonii
Copy link
Member

That bug isn't possible because the listener is registered before yielding to the event loop.

Going to close because it's not worth the translation churn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants