Typing indicators debounced at client and expire server-side on timeout
Why it matters
A typing indicator fired on every keystroke with no debounce generates roughly one WebSocket event per 100ms per active user. For a community with 100 simultaneous typists, that is 1,000 events per second — before any real messages are sent. Without server-side expiry, users who close their browser mid-compose are shown as typing indefinitely. Both failure modes inflate bandwidth, CPU cost, and connection noise for zero user-visible benefit, violating ISO 25010 performance-efficiency requirements.
Severity rationale
Medium because undebounced typing events generate excessive message volume that inflates server load and costs in proportion to the active user count.
Remediation
Debounce the client-side typing event to at most one emission per 500 ms, and expire server-side typing state after 10 seconds without an update.
// Client: debounce before emitting
let stopTimer: ReturnType<typeof setTimeout>;
const onInput = () => {
socket.emit('typing', { channel });
clearTimeout(stopTimer);
stopTimer = setTimeout(() => socket.emit('typing_stop', { channel }), 3_000);
};
input.addEventListener('input', onInput);
// Server: expire stale typing status
const typingTimers = new Map<string, ReturnType<typeof setTimeout>>();
socket.on('typing', ({ channel }) => {
if (typingTimers.has(socket.userId)) clearTimeout(typingTimers.get(socket.userId)!);
const t = setTimeout(() => {
removeTypingUser(channel, socket.userId);
broadcastTypingList(channel);
}, 10_000);
typingTimers.set(socket.userId, t);
addTypingUser(channel, socket.userId);
broadcastTypingList(channel);
});
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Real-Time Communication Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.resource-utilization — Resource utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from community-realtime·automated