diff --git a/static/js/activity.js b/static/js/activity.js index 0ccc423785..beeee72f33 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -308,11 +308,6 @@ function send_presence_to_server(want_redraw) { // DEFAULT_EVENT_QUEUE_TIMEOUT_SECS). server_events.check_for_unsuspend(); - if (reload_state.is_in_progress()) { - blueslip.log("Skipping querying presence because reload in progress"); - return; - } - channel.post({ url: '/json/users/me/presence', data: { diff --git a/static/js/blueslip.js b/static/js/blueslip.js index e41734e1de..3d2fd513d4 100644 --- a/static/js/blueslip.js +++ b/static/js/blueslip.js @@ -106,6 +106,9 @@ function report_error(msg, stack, opts) { // to include the CSRF token, our ajax call will fail. The // elegant thing to do in that case is to either wait until that // setup is done or do it ourselves and then retry. + // + // Important: We don't use channel.js here so that exceptions + // always make it to the server even if reload_state.is_in_progress. $.ajax({ type: 'POST', url: '/json/report/error', diff --git a/static/js/channel.js b/static/js/channel.js index 8a0fa2450f..b66cfaefd1 100644 --- a/static/js/channel.js +++ b/static/js/channel.js @@ -16,6 +16,13 @@ function remove_pending_request(jqXHR) { } function call(args, idempotent) { + if (reload_state.is_in_progress() && !args.ignore_reload) { + // If we're in the process of reloading, most HTTP requests + // are useless, with exceptions like cleaning up our event + // queue and blueslip (Which doesn't use channel.js). + return; + } + // Wrap the error handlers to reload the page if we get a CSRF error // (What probably happened is that the user logged out in another tab). let orig_error = args.error; diff --git a/static/js/server_events.js b/static/js/server_events.js index edd7c5769b..b141a8a821 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -318,6 +318,7 @@ exports.cleanup_event_queue = function cleanup_event_queue() { channel.del({ url: '/json/events', data: {queue_id: page_params.queue_id}, + ignore_reload: true, }); };