From 52c4cae23936687707409f90910e07b632b90951 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 27 Mar 2023 21:06:29 +0000 Subject: [PATCH] blueslip: Remove unused ui_message / show_ui_msg codepath. This was last used in 71e14674aaa7, a decade ago. --- web/src/blueslip.ts | 40 ++----------------------------------- zerver/tests/test_report.py | 3 +-- zerver/views/report.py | 2 -- 3 files changed, 3 insertions(+), 42 deletions(-) diff --git a/web/src/blueslip.ts b/web/src/blueslip.ts index f90e95d4c4..dc26c10306 100644 --- a/web/src/blueslip.ts +++ b/web/src/blueslip.ts @@ -10,7 +10,6 @@ import $ from "jquery"; import * as blueslip_stacktrace from "./blueslip_stacktrace"; import {page_params} from "./page_params"; -import * as ui_report from "./ui_report"; if (Error.stackTraceLimit !== undefined) { Error.stackTraceLimit = 100000; @@ -61,7 +60,7 @@ const last_report_attempt = new Map(); function report_error( msg: string, stack = "No stacktrace available", - {show_ui_msg = false, more_info}: {show_ui_msg?: boolean; more_info?: unknown} = {}, + more_info?: unknown, ): void { if (page_params.development_environment) { // In development, we display blueslip errors in the web UI, @@ -97,7 +96,6 @@ function report_error( web_version: ZULIP_VERSION, message: msg, stacktrace: stack, - ui_message: show_ui_msg, more_info: JSON.stringify(more_info), href: window.location.href, user_agent: window.navigator.userAgent, @@ -106,42 +104,8 @@ function report_error( timeout: 3 * 1000, success() { reported_errors.add(key); - if (show_ui_msg && ui_report !== undefined) { - // There are a few races here (and below in the error - // callback): - // 1) The ui_report module or something it requires might - // not have been compiled or initialized yet. - // 2) The DOM might not be ready yet and so fetching - // the #home-error div might fail. - - // For (1) we just don't show the message if the ui - // hasn't been loaded yet. The user will probably - // get another error once it does. We can't solve - // (2) by using $(document).ready because the - // callback never gets called (I think what's going - // on here is if the exception was raised by a - // function that was called as a result of the DOM - // becoming ready then the internal state of jQuery - // gets messed up and our callback never gets - // invoked). In any case, it will pretty clear that - // something is wrong with the page and the user will - // probably try to reload anyway. - ui_report.client_error( - "Oops. It seems something has gone wrong. " + - "The error has been reported to the fine " + - "folks at Zulip, but, in the mean time, " + - "please try reloading the page.", - $("#home-error"), - ); - } }, error() { - if (show_ui_msg && ui_report !== undefined) { - ui_report.client_error( - "Oops. It seems something has gone wrong. Please try reloading the page.", - $("#home-error"), - ); - } }, }); } @@ -223,7 +187,7 @@ export function warn(msg: string, more_info?: unknown): void { export function error(msg: string, more_info?: unknown, stack = new Error("dummy").stack): void { const args = build_arg_list(msg, more_info); logger.error(...args); - report_error(msg, stack, {more_info}); + report_error(msg, stack, more_info); if (page_params.development_environment) { throw new BlueslipError(msg, more_info); diff --git a/zerver/tests/test_report.py b/zerver/tests/test_report.py index 02c9144bc3..72299cd674 100644 --- a/zerver/tests/test_report.py +++ b/zerver/tests/test_report.py @@ -142,7 +142,6 @@ class TestReport(ZulipTestCase): dict( message="hello", stacktrace="trace", - ui_message=True, user_agent="agent", href="href", log="log", @@ -156,7 +155,7 @@ class TestReport(ZulipTestCase): self.assert_json_success(result) report = m.call_args[0][1]["report"] - for k in set(params) - {"ui_message", "more_info"}: + for k in set(params) - {"more_info"}: self.assertEqual(report[k], params[k]) self.assertEqual(report["more_info"], dict(foo="bar", draft_content="'**xxxxx**'")) diff --git a/zerver/views/report.py b/zerver/views/report.py index deec5adb32..cbe3dbc04f 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -123,7 +123,6 @@ def report_error( maybe_user_profile: Union[AnonymousUser, UserProfile], message: str = REQ(), stacktrace: str = REQ(), - ui_message: bool = REQ(json_validator=check_bool), user_agent: str = REQ(), href: str = REQ(), log: str = REQ(), @@ -168,7 +167,6 @@ def report_error( host=SplitResult("", request.get_host(), "", "", "").hostname, ip_address=remote_ip, user=user, - user_visible=ui_message, server_path=settings.DEPLOY_ROOT, server_version=server_version, web_version=web_version,