-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Fix intense CPU usage when sessionToken is invalid in liveQuery #5126
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
Conversation
…nToken fetch is invalid)
I don’t think it’s needed but test case? |
@dplewis this is a case that was overlooked initially. |
Codecov Report
@@ Coverage Diff @@
## master #5126 +/- ##
=========================================
- Coverage 93.8% 93.8% -0.01%
=========================================
Files 123 123
Lines 8915 8923 +8
=========================================
+ Hits 8363 8370 +7
- Misses 552 553 +1
Continue to review full report at Codecov.
|
// Check client sessionToken matches ACL | ||
const clientSessionToken = client.sessionToken; | ||
if (clientSessionToken) { | ||
const { userId } = await this.getAuthForSessionToken( |
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.
this was initally overlooked, the new implementation takes properly care of both tokens
@westhom this is the fix you are looking for. Probably the behaviour will require tweaking. Invalid session tokens should not issue server calls for 10 minutes (they may call after) and you should see performance improvements at large. |
); | ||
const { auth, userId } = await this.getAuthForSessionToken(token); | ||
|
||
// Getting the session token failed |
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.
fail fast
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.
lgtm. a solution to an immediate problem that can help @westhom and live query.
…e-community#5126) * Ensure we bail out early when auth or userId are not provided (sessionToken fetch is invalid) * Adds changelog * better handling of session token errors and client tokens
When sessionToken fetch failed through getAuthForSessionToken auth and userId would be undefined.
This PR ensure we do not throw an exception in this case.