diff --git a/js/expiring_messages.js b/js/expiring_messages.js index ed3e15faa..887f4c13c 100644 --- a/js/expiring_messages.js +++ b/js/expiring_messages.js @@ -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); });