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

beforeMessageBodyTransformed plugin hooks (and others) are not respecting async/await #3342

Open
OCDolan opened this issue Mar 7, 2024 · 1 comment
Milestone

Comments

@OCDolan
Copy link

OCDolan commented Mar 7, 2024

Describe the bug
beforeMessageBodyTransformed plugin hooks (and others) are not respecting async/await

To Reproduce
Steps to reproduce the behavior:
_converse.api.listen.on('beforeMessageBodyTransformed', async (text, view) => {
console.log("beforeMessageBodyTransformed");
await something(text); // This await doesn't work, because beforeMessageBodyTransformed returns immedietly!
});

Expected behavior
beforeMessageBodyTransformed should wait untill await something(text) finishes before starting afterMessageBodyTransformed

Screenshots
None

Environment (please complete the following information):

  • Desktop or Mobile? Affects all
  • Browser [e.g. Chrome, Firefox] Affects all
  • Converse.js version [e.g. 4.2.0] Latest

Additional context
None

!!! CAUSE + HOW TO FIX !!!
The cause of the bug is a capitalization error in rich-text.js.
await api.trigger('beforeMessageBodyTransformed', this, { 'Synchronous': true }); should be await api.trigger('beforeMessageBodyTransformed', this, { 'synchronous': true });
synchronous not Synchronous!

I think this affects several plugin hooks, not just this one i've found, it might be worth doing a regex to find all instances of this bug.

Thanks!

@OCDolan
Copy link
Author

OCDolan commented Mar 7, 2024

FYI i've found it in 5 places - chatBoxInitialized, messageInitialized, chatRoomInitialized, rosterContactInitialized, afterMessageBodyTransformed

@jcbrand jcbrand modified the milestone: 11.0.0 Sep 12, 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

No branches or pull requests

2 participants