-
-
Notifications
You must be signed in to change notification settings - Fork 133
Delete Pending requests on switch account / logout #2565
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you test this?
It does not work, see video:
2025-09-21.16-32-03.mp4
I will add this video to the issue because this is the same test I did to demonstrate that #2406 (review) does not work.
I also added a new possible hint how to fix this in the issue.
lib/auth.js
Outdated
export const clearAuthCookies = () => { | ||
const expiredDate = 'Thu, 01 Jan 1970 00:00:00 GMT' | ||
document.cookie = `${SESSION_COOKIE}=; path=/; expires=${expiredDate}` | ||
document.cookie = `${MULTI_AUTH_POINTER}=; path=/; expires=${expiredDate}` | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think JS can clear httpOnly cookies in production
lib/apollo.js
Outdated
function getClient (uri) { | ||
const authContextLink = setContext((_, { headers }) => { | ||
if (SSR) return { headers } | ||
if (typeof window !== 'undefined' && window.logoutInProgress) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers
is always undefined here
components/nav/common.js
Outdated
window.logoutInProgress = true | ||
clearAuthCookies() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might not hit this line during logout because we get switched to another account, see code above
the code above is also prone to the race condition
components/account.js
Outdated
// prevent navigation | ||
e.preventDefault() | ||
|
||
if (typeof window !== 'undefined') window.logoutInProgress = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the assumption that this variable is reset when the page is reloaded?
i tested using something like this: |
This is fetching every 5 seconds, but the bug is about requests that take 5 seconds to finish |
After spending some time in the documentations you suggested, I implemented a custom Apollo Link that injects 2025-09-21-19-56-11.mp4 |
Description
fix #2366
Fixed race condition:
Screenshots
NaN
Additional Context
Uses Apollo Client's setContext link for clean request interception, clearAuthCookies() function can be reused for other logout scenarios
Checklist
Are your changes backward compatible? Please answer below:
Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
8/10
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
NaN
Did you introduce any new environment variables? If so, call them out explicitly here:
NaN
Did you use AI for this? If so, how much did it assist you?
I used AI to locate interested files and to test the implementations