Skip to content

Comments

fix(api): prevent main thread freeze in typing handler & fix login typo#1165

Open
vivekyadav-3 wants to merge 2 commits intoRocketChat:developfrom
vivekyadav-3:fix/clean-ref-error
Open

fix(api): prevent main thread freeze in typing handler & fix login typo#1165
vivekyadav-3 wants to merge 2 commits intoRocketChat:developfrom
vivekyadav-3:fix/clean-ref-error

Conversation

@vivekyadav-3
Copy link

This PR addresses two issues in the @embeddedchat/api:

Typing Handler Freeze: Replaced a blocking while loop with a non-blocking async wait in
handleTypingEvent to prevent potential main thread freezes.
Login Typo: Fixed an accidental double-assignment typo in the login method

Copilot AI review requested due to automatic review settings February 20, 2026 09:48
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two issues in the EmbeddedChatApi: a double-assignment typo in the login method and a blocking while loop in the typing event handler that could freeze the main thread.

Changes:

  • Fixed double-assignment typo credentials = credentials = to credentials = in the login method
  • Converted handleTypingEvent from synchronous to asynchronous with non-blocking wait loop
  • Added try-finally block to ensure typing handler lock is always released

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const newTypingStatus = cloneArray(this.typingUsers);
this.onTypingStatusCallbacks.forEach((callback) =>
callback(newTypingStatus)
);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The async method can throw errors, but there's no error handling in the try block, and callers don't await the promise. If an error occurs while manipulating typingUsers or invoking callbacks (e.g., if a callback throws), it will result in an unhandled promise rejection. Consider adding a catch block to log errors or handle them gracefully.

Suggested change
);
);
} catch (error) {
console.error("Error while handling typing event:", error);

Copilot uses AI. Check for mistakes.
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.

3 participants