fix(replay): Streamline session creation/refresh#8813
Conversation
4ef8232 to
0ec5bf6
Compare
size-limit report 📦
|
billyvg
left a comment
There was a problem hiding this comment.
LGTM, will do some manual testing tomorrow
|
Hmm do we not use codecov in this repo? |
| // Else, we are not buffering, and the session is expired, so we need to create a new one | ||
| logInfoNextTick('[Replay] Session has expired, creating new one...', traceInternals); | ||
|
|
||
| const newSession = createSession(sessionOptions, { previousSessionId: session.id }); |
Check failure
Code scanning / CodeQL
Insecure randomness
|
Seeing an issue where we have stale events being flushed alongside the new session, Francesco will be looking into this tomorrow. |
afe8493 to
ebf8ba6
Compare
ebf8ba6 to
6b77c3c
Compare
|
Note: I updated this PR to fix another bug: Now, when we restore a session for sessionStorage, we only start in |
We've been using
_loadAndCheckSessionboth in initial session setup as well as when checking for expiration of session.This leads to some not-so-optimized stuff, as we kind of have to do double duty in there (e.g. we constantly re-assign the session etc).
This streamlines this by splitting this into:
_initializeSessionForSampling(): Only called ininitializeSampling()_checkSession(): Called everywhere else, assumes we have a session setup yetOnly the former actually looks into sessionStorage, the latter can assume we always have a session already.
This also extends the behavior so that if we fetch a
buffersession from storage and segment_id > 0, we start the session insessionmode. Without this, we could theoretically run into endless sessions if the user keeps refreshing and keeps having errors, leading to continuous switchovers from buffer>session mode.