I got a 502 error here on Meta today. Apart from the pop up, I didn’t notice any unexpected behavior. I am not really sure what caused this, and I am not consistently able to reproduce it, but I was able to trigger it a few times.
Here is what I did:
I used the + in the sidebar to open the DM chat with someone I talked to before but who is currently not in my sidebar.
I used the full-screen chat button.
I changed the size of the browser window so it was smaller.
I made the browser window full screen again.
I switched from full-screen chat back to the small chat window.
There was an bad query that was used to return the count of users with chat enabled in the chat group serializer and it was taking ~30s for your account which is the request timeout on our hosting (hence why you were getting it “randomly”)
My first fix only addressed part of the issue There was another inefficient database query happening when searching for groups in the chat filter. Depending on which groups matched your search term, the query could take a very long time to complete – sometimes exceeding our request timeout.
Interestingly, this only affected “regular” users and not “admins”, hence why I wasn’t able to reproduce myself
When searching for groups, results are returned alphabetically. Admins can see all groups, so their first 10 results for “L” were small groups starting with ‘a’ (like “ai-personas” and other non-public groups). Regular users have more limited visibility, so their results included the large trust level groups , which is what caused the slow query.