LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.29k stars 884 forks source link

rust `.expects` causing actix crashes and Toastify errors #5192

Closed dessalines closed 1 day ago

dessalines commented 5 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 5 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 5 months ago

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

matc-pub commented 5 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 5 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 5 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 5 months ago

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

dessalines commented 5 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 5 months ago

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

dessalines commented 5 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 3 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 3 months ago

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

Crashdoom commented 2 weeks ago

This seems to be fairly consistent on pawb.social and I've not been able to identify why it occurs. All I can ascertain is that Lemmy closes the connection and causes a 502 error in Nginx, which then gives an HTML response that it's not expecting, and so "Toastify is awesome"

Log from Nginx

2024/10/29 17:11:25 [error] 34#34: *2972 upstream prematurely closed connection while reading response header from upstream, client: [removed], server: localhost, request: "POST /api/v3/comment HTTP/1.1", upstream: "http://[removed]:8536/api/v3/comment", host: "pawb.social", referrer: "https://pawb.social/post/15502880"
[removed] - - [29/Oct/2024:17:11:25 +0000] "POST /api/v3/comment HTTP/1.1" 502 150 "https://pawb.social/post/15502880" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15"

I did find this in the logs around the same time as my second attempt:

Log from Nginx

[removed] - - [29/Oct/2024:17:16:02 +0000] "POST /api/v3/comment HTTP/1.1" 502 150 "https://pawb.social/post/15502880" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15"

Log from Lemmy

thread 'actix-server worker 0' panicked at /lemmy/crates/utils/src/email.rs:53:10:
email from address isn't valid: InvalidInput

It seems to be related to the smtp_from_address which we have set to Pawb.Social Lemmy <noreply@{{ domain }}> (This is entirely an error on my part and apparently one of the variables didn't get copied across correctly, but it might be worth handling the InvalidInput to avoid it crashing out the entire process and log / note a warning somewhere).

Fixing the incorrect email (in our case) appears to have resolved the issue.

dessalines commented 4 days ago

Thx! those logs help... I see some expects in that file which shouldn't be there.