You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WorkerHandler blocks the main thread under event bursts #20547
WorkerHandler.postMessage in @sentry-internal/replay attaches a fresh 'message' listener to the compression worker for every request, and removes it only when the matching response arrives. Under a burst of N in-flight requests, every worker response is dispatched to all N attached listeners (each then runs an id/method check and returns), producing O(n²) main-thread dispatch work.
This was hit in production by two enterprise customers when Zendesk's web widget started inserting CSS rules at high frequency: rrweb emitted a mutation per rule, Replay forwarded each via postMessage, and the listener fan-out made the page unresponsive for several seconds.
publicpostMessage<T>(method,arg): Promise<T>{constid=this._getAndIncrementId();returnnewPromise((resolve,reject)=>{constlistener=({ data })=>{if(response.method!==method)return;if(response.id!==id)return;this._worker.removeEventListener('message',listener);// resolve/reject…};this._worker.addEventListener('message',listener);// ← N listeners during burstthis._worker.postMessage({ id, method, arg });});}
Activity
linear-code commentedon Apr 28, 2026
JS-2308
fix(replay): Avoid main-thread blocking in WorkerHandler under event …
fix(replay): Avoid main-thread blocking in WorkerHandler under event …
sbimochan commentedon Apr 29, 2026
Amazing! will test it out soon.
github-actions commentedon Apr 29, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #20548, which was included in the 10.51.0 release.