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

bugfix: unhandled exception in disconnect function #3435

Conversation

izinin
Copy link
Contributor

@izinin izinin commented Jul 5, 2024

bugfix: unhandled exception in disconnect function when chat panel is not shown by UI

Thanks for making a pull request to converse.js!

Before submitting your request, please make sure the following conditions are met:

  • Add a changelog entry for your change in CHANGES.md
  • When adding a configuration variable, please make sure to
    document it in docs/source/configuration.rst
  • Please add a test for your change. Tests can be run in the commandline
    with make check or you can run them in the browser by running make serve
    and then opening http://localhost:8000/tests.html.

return view;
try{
const view = _converse.state.chatboxviews.get('controlbox');
view.model.set({ 'connected': false });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the error/exception that you're seeing?

If it's due to view not being defined, then you can do:

view?.model.set({ connected: false });

@izinin
Copy link
Contributor Author

izinin commented Jul 8, 2024 via email

@jcbrand
Copy link
Member

jcbrand commented Jul 19, 2024

i need something to return in promise because it is async operation in you fix variant i will return null which will cause blowing somewhere else. That is why there is no ? operator

I would still like to know what the actual error is that you're getting, so that I can better understand the underlying issue.

Simply wrapping a statement with a blanket try/catch is usually not the best solution.

@izinin
Copy link
Contributor Author

izinin commented Jul 19, 2024

this is timing issue , _converse.state.chatboxviews might not be created yet when a view is requested.
Due to asynchronous the application nature and not constant network conditions this issue is not 100% reproducible but does happen. When there is unhandled exception in ConverseJS chat becomes blank. This issue considerable impacts users experience.
We need to use defensive programming in such conditions assuming any function in the run path can fail. We either propagate error up to the call stack or silently return. This is the second case

Also , please kindly reject the PR if you consider it not to go to the mainline

@jcbrand
Copy link
Member

jcbrand commented Jul 20, 2024

I've merged your commit manually, but then made a change, because I don't think blanket try/catch is usually the right way to go. Also, it doesn't look like the function needs to return anything.

@jcbrand jcbrand closed this Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants