Skip to content

Commit 0edca51

Browse files
committed
remove unnecessary duplicate script detection
1 parent a81a4dd commit 0edca51

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

templates/base/head_script.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
66
<script>
77
window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
88
window.config = {
9-
initCount: (window.config?.initCount ?? 0) + 1,
109
appUrl: '{{AppUrl}}',
1110
appSubUrl: '{{AppSubUrl}}',
1211
assetVersionEncoded: encodeURIComponent('{{AssetVersion}}'), // will be used in URL construction directly

templates/status/500.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
</div>
4343
</div>
4444

45-
{{/* when a sub-template triggers an 500 error, its parent template has been partially rendered,
46-
then the 500 page will be rendered after that partially rendered page, the HTML/JS are totally broken.
47-
so use this inline script to try to move it to main viewport */}}
45+
{{/* When a sub-template triggers an 500 error, its parent template has been partially rendered, then the 500 page
46+
will be rendered after that partially rendered page, the HTML/JS are totally broken. Use this inline script to try to move it to main viewport.
47+
And this page shouldn't include any other JS file, avoid duplicate JS execution (still due to the partial rendering).*/}}
4848
<script type="module">
4949
const embedded = document.querySelector('.page-content .page-content.status-page-500');
5050
if (embedded) {

web_src/js/bootstrap.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export function showGlobalErrorMessage(msg) {
2020
* @param {ErrorEvent} e
2121
*/
2222
function processWindowErrorEvent(e) {
23-
if (window.config.initCount > 1) {
24-
// the page content has been loaded many times, the HTML/JS are totally broken, don't need to show error message
25-
return;
26-
}
2723
if (!e.error && e.lineno === 0 && e.colno === 0 && e.filename === '' && window.navigator.userAgent.includes('FxiOS/')) {
2824
// At the moment, Firefox (iOS) (10x) has an engine bug. See https://github.com/go-gitea/gitea/issues/20240
2925
// If a script inserts a newly created (and content changed) element into DOM, there will be a nonsense error event reporting: Script error: line 0, col 0.
@@ -37,13 +33,6 @@ function initGlobalErrorHandler() {
3733
if (!window.config) {
3834
showGlobalErrorMessage(`Gitea JavaScript code couldn't run correctly, please check your custom templates`);
3935
}
40-
if (window.config.initCount > 1) {
41-
// when a sub-templates triggers an 500 error, its parent template has been partially rendered,
42-
// then the 500 page will be rendered after that partially rendered page, which will cause the initCount > 1
43-
// in this case, the page is totally broken, so do not do any further error handling
44-
console.error('initGlobalErrorHandler: Gitea global config system has already been initialized, there must be something else wrong');
45-
return;
46-
}
4736
// we added an event handler for window error at the very beginning of <script> of page head
4837
// the handler calls `_globalHandlerErrors.push` (array method) to record all errors occur before this init
4938
// then in this init, we can collect all error events and show them

0 commit comments

Comments
 (0)