Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript promise rejection: TypeError: Cannot read properties of undefined (reading 'facebook.json'). Open browser console to see more details. #29273

Closed
xiaoxinpro opened this issue Feb 20, 2024 · 9 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail topic/ui Change the appearance of the Gitea UI

Comments

@xiaoxinpro
Copy link

Description

Gitea upgraded from 1.20.5 to 1.21.5, and the Web frontend gives an error:

JavaScript promise rejection: TypeError: Cannot read properties of undefined (reading 'facebook.json'). Open browser console to see more details.

The problem persisted even after Chrome's cache was cleared.

browser console output:

VM32:8298 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'facebook.json')
    at getConfig (<anonymous>:8298:42)
    at ClickToLoad.init (<anonymous>:11099:37)
    at ClickToLoad.callInit (<anonymous>:3140:18)
    at <anonymous>:11401:33
    at Array.forEach (<anonymous>)
    at Object.init (<anonymous>:11399:26)
getConfig @ VM32:8298
init @ VM32:11099
callInit @ VM32:3140
(anonymous) @ VM32:11401
init @ VM32:11399
await in init (async)
apply @ VM32:11467
(anonymous) @ VM50:3
(anonymous) @ VM50:5
inject @ inject.js:114
(anonymous) @ inject.js:211
Show 2 more frames
Show less

Screenshots

image

Gitea Version

1.21.5

Can you reproduce the bug on the Gitea demo site?

No

Operating System

Windowns

Browser Version

Chrome 121.0.6167.185

@xiaoxinpro xiaoxinpro added topic/ui Change the appearance of the Gitea UI type/bug labels Feb 20, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 20, 2024

It is caused by your browser extension's bug.

https://stackoverflow.com/questions/76723154/uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-f

If you don't like to see the message, you could add your customized CSS styles to hide such prompts (.js-global-error { display: none; }

@wxiaoguang wxiaoguang added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed type/bug labels Feb 20, 2024
@xiaoxinpro
Copy link
Author

It is caused by your browser extension's bug.

https://stackoverflow.com/questions/76723154/uncaught-in-promise-typeerror-cannot-read-properties-of-undefined-reading-f

If you don't like to see the message, you could add your customized CSS styles to hide such prompts (.js-global-error { display: none; }

@wxiaoguang Thanks, If it is a browser extension bug, try.gitea.io is fine.

@xiaoxinpro
Copy link
Author

Closing the browser extension DuckDuckGo can resolve this issue

@silverwind
Copy link
Member

silverwind commented Feb 20, 2024

Maybe we can somehow detect when a error is not coming from our scripts, and don't display errors from third-party scripts based on script file path.

@silverwind
Copy link
Member

silverwind commented Feb 20, 2024

Can someone link the extension that causes this from Chrome Store/Mozilla Addons?

@wxiaoguang
Copy link
Contributor

Maybe we can somehow detect when a error is not coming from our scripts, and don't display errors from third-party scripts like extensions.

And maybe it's time to stop showing the JS errors to end users? Only show it in dev mode and for site admin?

@silverwind
Copy link
Member

Maybe we can somehow detect when a error is not coming from our scripts, and don't display errors from third-party scripts like extensions.

And maybe it's time to stop showing the JS errors to end users? Only show it in dev mode and for site admin?

That'd also be an option, but I'm not sure I like it too much because sometimes we do get valuable issue reports from it.

@silverwind
Copy link
Member

Can be reproduced with a Violentmonkey script:

// ==UserScript==
// @name        Gitea error trigger
// @match       http:https://localhost:3000/*
// ==/UserScript==
(async () => {
  throw new Error("error from userscript");
})()

@silverwind
Copy link
Member

silverwind commented Feb 20, 2024

So I checked it: It is possible in Firefox to detect extension scripts via error.stack?.includes('moz-extension:https://'), but that does not work in Chrome which shows nothing clearly identifyable. So yes I think we should go with @wxiaoguang's suggestion.

silverwind added a commit that referenced this issue Feb 22, 2024
So we don't get issues like
#29080 and
#29273 any more. Only active in
[production
builds](https://webpack.js.org/guides/production/#specify-the-mode), in
non-production the errors will still show.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Feb 22, 2024
So we don't get issues like
go-gitea#29080 and
go-gitea#29273 any more. Only active in
[production
builds](https://webpack.js.org/guides/production/#specify-the-mode), in
non-production the errors will still show.
silverwind added a commit that referenced this issue Feb 22, 2024
Backport #29303 by @silverwind

So we don't get issues like
#29080 and
#29273 any more. Only active in
[production
builds](https://webpack.js.org/guides/production/#specify-the-mode), in
non-production the errors will still show.

Co-authored-by: silverwind <[email protected]>
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this issue Feb 27, 2024
So we don't get issues like
go-gitea/gitea#29080 and
go-gitea/gitea#29273 any more. Only active in
[production
builds](https://webpack.js.org/guides/production/#specify-the-mode), in
non-production the errors will still show.

(cherry picked from commit 532da5ed5ee3edb45d2ee63c6ab0fad53473691f)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

No branches or pull requests

4 participants