mirror of https://github.com/zulip/zulip.git
channel: Don't send outgoing HTTP requests during a reload.
This generalizes existing code for the presence code path that is generically useful for avoiding useless work that will be discarded. We make an exception for the one type of request that needs to happen while reloading, namely the one to clean up our event queue.
This commit is contained in:
parent
e2892a88c1
commit
c2f132b8d5
|
@ -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: {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue