Skip to content
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

fix(replay): Do not renew session in error mode #6948

Merged
merged 2 commits into from
Jan 26, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 26, 2023

Currently, when you have a replay session running because of an error, and the session expires (after 15min of inactivity or 60min of activity), we just create a new session (again in error mode) and continue recording.

This is confusing because from a users perspective, they see replays in error mode but with (potentially) no error connected to it.

This PR changes this behavior - when in error mode, and the session expires, we stop the replay.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.83 KB (-0.02% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.48 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.5 KB (-0.02% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 54.79 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.22 KB (0%)
@sentry/browser - Webpack (minified) 66.19 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.25 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.54 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.75 KB (-0.02% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.03 KB (-0.02% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.68 KB (+0.26% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.46 KB (+0.37% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.01 KB (+0.17% 🔺)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I think stopping in this case makes sense.

@@ -369,6 +369,52 @@ describe('Integration | errorSampleRate', () => {
]),
});
});

it('stops replay when session expires', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only want this for the error mode, right? Do we have tests in the session recording mode that check the expected behavior there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 374 to 381
// We know this is set, because it is always set in _loadSession
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!this.session!.sampled) {
this.stop();
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check be done in _loadSession?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually moved this to a new method.

Comment on lines 261 to 276
if (!this.session || !this.session.sampled) {
this.stop();
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have this call loadSession?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!

Comment on lines 883 to 894
private _loadAndCheckSession(expiry?: number): boolean {
this._loadSession(expiry);

// We know this is set, because it is always set in _loadSession
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!this.session!.sampled) {
this.stop();
return false;
}

return true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the cases where we want to load session but not check sampled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think on start, because there we do some more stuff (incl. also checking this). but maybe actually we can also just use this there, looking at it again - I'll unify it!

@@ -228,6 +230,10 @@ export class ReplayContainer implements ReplayContainerInterface {
* does not support a teardown
*/
public stop(): void {
if (!this._isEnabled) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this check to ensure we do not stop multiple times.

@mydea mydea merged commit 69b46b3 into master Jan 26, 2023
@mydea mydea deleted the fn/replay-error-mode branch January 26, 2023 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants