Add a max setTimout for expiring messages (over max == immediate)

Discovered a user log where expiring message checks were happening
constantly. This ensures that a very large timeout doesn't roll over
into immediate callbacks.

FREEBIE
pull/749/head
Scott Nonnenberg 8 years ago
parent e57f155403
commit e7450fa0d7

@ -31,8 +31,13 @@
console.log('next message expires', new Date(expires_at).toISOString());
var wait = expires_at - Date.now();
// In the past
if (wait < 0) { wait = 0; }
// Too far in the future, since it's limited to a 32-bit value
if (wait > 2147483647) { wait = 2147483647; }
clearTimeout(timeout);
timeout = setTimeout(destroyExpiredMessages, wait);
});

Loading…
Cancel
Save