reactions: Do not send server error reports for duplicate requests.

This commit is contained in:
Alex Vandiver 2023-07-18 18:01:27 +00:00 committed by Tim Abbott
parent 871a668dd2
commit d05a9d4000
2 changed files with 10 additions and 3 deletions

View File

@ -85,8 +85,15 @@ function update_ui_and_send_reaction_ajax(message_id, reaction_info) {
},
error(xhr) {
view.waiting_for_server_request_ids.delete(reaction_request_id);
const response = channel.xhr_error_message("Error sending reaction", xhr);
blueslip.error(response);
if (
xhr.responseJSON?.code === "REACTION_ALREADY_EXISTS" ||
xhr.responseJSON?.code === "REACTION_DOES_NOT_EXIST"
) {
// Don't send error report for simple precondition failures caused by race
// conditions; the user already got what they wanted
} else {
blueslip.error(channel.xhr_error_message("Error sending reaction", xhr));
}
},
};

View File

@ -268,7 +268,7 @@ test("sending", ({override, override_rewire}) => {
// Since this path calls blueslip.warn, we need to handle it.
blueslip.expect("error", "XHR error message.");
channel.xhr_error_message = () => "XHR error message.";
args.error();
args.error({responseJSON: {msg: "Some error message"}});
}
emoji_name = "alien"; // not set yet
{