LemmyNet / lemmy-ui

The official web app for lemmy.
https://join-lemmy.org/
GNU Affero General Public License v3.0
888 stars 334 forks source link

Toastify error toasts broke with a recent update #2510

Open dessalines opened 4 months ago

dessalines commented 4 months ago

Requirements

Summary

For various error / removal toasts, I'm getting a "Toastify is awesome!" message, rather than the intended message.

Steps to Reproduce

  1. Try to remove a comment
  2. See wrong message

Technical Details

NA

Lemmy Instance Version

main

Lemmy Instance URL

https://voyager.lemmy.ml

EDIT: actually wait, comment removals and restore isn't the correct test. I'll have to find what's creating this.

dessalines commented 4 months ago

Ahhh I can't even replicate it now, but I've seen two people besides myself see this toast. I can't find where its coming from in the code also, besides some possible toasts where its calling JSON.stringify(res.error.message)

SleeplessOne1917 commented 4 months ago

Even stranger, according to the git blame, the toastify dependency hasn't been updated in 22 months. 😕

matc-pub commented 4 months ago

I added a few places that now report error messages that previously didn't. Looks like i18n returns an empty string for unknown keys, which then makes toastify feel awesome. This makes toastify show the key instead:

--- a/src/shared/services/I18NextService.ts
+++ b/src/shared/services/I18NextService.ts
@@ -187,7 +187,7 @@ export class I18NextService {
         nonExplicitSupportedLngs: true,
         load: "all",
         // initImmediate: false,
-        fallbackLng: "en",
+        fallbackLng: ["en", "code"],
         resources: { en } as Resource,
         interpolation: { format },
         partialBundledLanguages: true,

Edit: Irrelevant now, but "code" should have been "cimode"

SleeplessOne1917 commented 4 months ago

Looks like i18n returns an empty string for unknown keys, which then makes toastify feel awesome.

Is this happening in English, or only non-English languages? en.json always gets updated first since it's the language the maintainers are all fluent in, however translations for other languages can lag behind, especially ones that aren't used by much of the userbase.

matc-pub commented 4 months ago

Is this happening in English, or only non-English languages?

Now I always get the key for unknown keys, even without the change from above. When it did happen it was with "Browser Default" and en-US.

SleeplessOne1917 commented 4 months ago

Odd. @dessalines have any other users encountered this issue?

dessalines commented 4 months ago

Myself and davel have seen it. I'm fairly sure it's not in a place with an explicit key named, but one of the ones stringifying an error message.

SleeplessOne1917 commented 4 months ago

Has anyone encountered this consistently? I encountered this bug once in the wild, but was unable to replicate it.

dessalines commented 4 months ago

Same, haven't been able to either. I think I've just gotta close until we can actually replicate it.

jcklpe commented 4 months ago

I just got it too
 

It happened after I tried submitting a post. It didn't post, this popped up, and then I clicked a second time (after screenshotting) and it then posted correctly.

SleeplessOne1917 commented 2 months ago

@matc-pub

Do you know how to consistently get the unknown key error like you did in your last 2 comments? I tried adding an extra non-existent fallback language like this comment, but I can't reproduce it.

dessalines commented 2 months ago

Bumping back to 0.20.0 , since we can't repro.