Skip to content

Comments

fix: remove blocking busy-wait in handleTypingEvent (#1151)#1164

Open
Ayush-AM wants to merge 1 commit intoRocketChat:developfrom
Ayush-AM:1151
Open

fix: remove blocking busy-wait in handleTypingEvent (#1151)#1164
Ayush-AM wants to merge 1 commit intoRocketChat:developfrom
Ayush-AM:1151

Conversation

@Ayush-AM
Copy link

@Ayush-AM Ayush-AM commented Feb 20, 2026

Fix: Remove blocking busy-wait in handleTypingEvent

Acceptance Criteria fulfillment

  • Analyzed handleTypingEvent for blocking code
  • Removed while (typingHandlerLock) {} busy-wait loop
  • Implemented non-blocking, synchronous queue logic for typing updates
  • Verified build and responsiveness during typing events

Fixes #1151

PR Test Details

The handleTypingEvent function previously used a busy-wait loop that blocked the main thread, causing the UI to freeze when multiple typing events were received.

This PR removes the locking mechanism and the while loop entirely. It replaces the logic with standard synchronous array operations (splice and unshift), which are non-blocking and safe for JavaScript's single-threaded event loop. This ensures that typing indicators update smoothly without degrading UI performance.

@Ayush-AM
Copy link
Author

This PR addresses the critical performance issue where the UI would freeze during rapid typing events.
The root cause was a busy-wait loop (while (typingHandlerLock) {}) inside handleTypingEvent in packages/api/src/EmbeddedChatApi.ts. This loop blocked the main JavaScript thread, preventing the event loop from processing other tasks, including the setTimeout intended to release the lock, effectively causing a deadlock and freezing the UI.

@CLAassistant
Copy link

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

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.

Critical: handleTypingEvent busy-wait blocks main thread and freezes UI during typing updates

2 participants