From 6d2ae9abbc641b6df4e5bdc0719b1e06da2189a2 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 30 Mar 2016 23:01:52 -0700 Subject: [PATCH] Fix cleanup_event_queue being called multiple times during reload. Apparently it isn't always the case that removal of jquery and the DOM prevents cleanup_event_queue from being called via the postunload hook, so add a check to avoid it being double-called. --- static/js/reload.js | 4 ++-- static/js/server_events.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/static/js/reload.js b/static/js/reload.js index e6c1a7937b..0493224032 100644 --- a/static/js/reload.js +++ b/static/js/reload.js @@ -150,8 +150,8 @@ function cleanup_before_reload() { // Free all the DOM in the main_div $("#main_div").empty(); - // Now that the DOM is empty our beforeunload callback has been - // removed. + // Now that the DOM is empty our beforeunload callback may + // have been removed, so explicitly remove event queue here. server_events.cleanup_event_queue(); // Empty the large collections diff --git a/static/js/server_events.js b/static/js/server_events.js index 54d9ee073e..6826258e00 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -379,6 +379,8 @@ exports.cleanup_event_queue = function cleanup_event_queue() { if (page_params.event_queue_expired === true) { return; } + // Set expired because in a reload we may be called twice. + page_params.event_queue_expired = true; channel.del({ url: '/json/events', data: {queue_id: page_params.event_queue_id}