You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a single bug. Do not report multiple bugs in one issue.
It's a frontend issue, not a backend issue; Otherwise please create an issue on the backend repo instead.
Summary
I heard that multiple people have allegedly experienced a situation where they load a page and are logged in as a different user - either very shortly until the page rerenders or possibly until a page refresh.
I looked at the code and it seems there might be a fairly simple explanation due to a race condition (I don't know much about Inferno, just React/SSR).
Which sets the global UserService. After that, it does an asynchronous call to await activeRoute.fetchInitialData(initialFetchReq); During this time, the UserService.instance.userData may be replaced by a separate incoming http request. After that, it calls renderToString which will create the various JSX components.
In those, the user context is used both in class componets and via the myAuth() function, e.g.:
Requirements
Summary
I heard that multiple people have allegedly experienced a situation where they load a page and are logged in as a different user - either very shortly until the page rerenders or possibly until a page refresh.
I looked at the code and it seems there might be a fairly simple explanation due to a race condition (I don't know much about Inferno, just React/SSR).
The catch all request handler:
lemmy-ui/src/server/handlers/catch-all-handler.tsx
Line 25 in 3d58bae
calls initializeSite()
lemmy-ui/src/shared/utils/app/initialize-site.ts
Lines 5 to 6 in 3d58bae
Which sets the global UserService. After that, it does an asynchronous call to
await activeRoute.fetchInitialData(initialFetchReq);
During this time, the UserService.instance.userData may be replaced by a separate incoming http request. After that, it callsrenderToString
which will create the various JSX components.In those, the user context is used both in class componets and via the myAuth() function, e.g.:
https://github.com/LemmyNet/lemmy-ui/blob/main/src/shared/components/app/app.tsx
At which point it might be the data from a different user though.
I think the solution would be to store UserService inside the react context instead of using a singleton.
Steps to Reproduce
I have not reproduced this issue.
Technical Details
Lemmy Instance Version
current main branch
Lemmy Instance URL
No response
The text was updated successfully, but these errors were encountered: