From 424a745c4a2663304566b5976139b21155d6580d Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 18 Jan 2024 18:33:40 +0100 Subject: [PATCH] [GITEA] Limit amount of javascript errors being shown - Currently an unlimited amount of errors could be shown to the user, this can cause that if something goes wrong the user will be shown a big wall of errors, even when Forgejo in most cases can still be used. - Therefor limit to three errors being shown, as it's unlikely that three seperate javascript errors needs to be shown, they are likely to be related and the console still shows all of the errors. --- web_src/js/bootstrap.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web_src/js/bootstrap.js b/web_src/js/bootstrap.js index 15e5b21204..a2fe3d2ecd 100644 --- a/web_src/js/bootstrap.js +++ b/web_src/js/bootstrap.js @@ -8,6 +8,8 @@ __webpack_public_path__ = `${window.config?.assetUrlPrefix ?? '/assets'}/`; export function showGlobalErrorMessage(msg) { const pageContent = document.querySelector('.page-content'); if (!pageContent) return; + // Prevent a wall of errors being presented to the user. + if (document.querySelectorAll('.js-global-error').length >= 3) return; const el = document.createElement('div'); el.innerHTML = `
`; el.childNodes[0].textContent = msg;