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

feat(replay): Stop without retry when receiving bad API response #6773

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 16, 2023

This is based on #6765!

This ensures that when we hit a "bad" API response, instead of continuing - which we do now, which will lead to missing segments - we stop the replay immediately.

We do not do any retries in this case, as that could lead to us e.g. hammering the API when there is a problem, which we need to avoid.

I've spent way to much time getting this to work in the "classic" test setup we have, and eventually gave up and wrote a integration test instead. For what it's worth, the problem seems to be with resetting stuff & mocks when we have multiple tests in a row (it worked when running tests one by one). It is very weird, but a problem to be solved with more time, I'd say. For now, the test should be good.

@mydea mydea requested review from billyvg and Lms24 January 16, 2023 07:54
@mydea mydea self-assigned this Jan 16, 2023
@@ -234,6 +234,7 @@ export class ReplayContainer implements ReplayContainerInterface {
this._stopRecording?.();
this.eventBuffer?.destroy();
this.eventBuffer = null;
this._debouncedFlush.cancel();
Copy link
Member Author

Choose a reason for hiding this comment

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

Just a small thing I noticed while debugging tests.

Copy link
Member

Choose a reason for hiding this comment

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

good catch!

@@ -907,7 +908,7 @@ export class ReplayContainer implements ReplayContainerInterface {
if (rateLimitDuration > 0) {
__DEBUG_BUILD__ && logger.warn('[Replay]', `Rate limit hit, pausing replay for ${rateLimitDuration}ms`);
this.pause();
this._debouncedFlush && this._debouncedFlush.cancel();
this._debouncedFlush.cancel();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is set in the constructor, so no need to check for existence here.

@@ -5,7 +5,7 @@ import type { DomHandler } from './../types';
import type { MockSdkParams } from './mockSdk';
import { mockSdk } from './mockSdk';

export async function resetSdkMock({ replayOptions, sentryOptions }: MockSdkParams): Promise<{
export async function resetSdkMock({ replayOptions, sentryOptions, autoStart }: MockSdkParams): Promise<{
Copy link
Member Author

Choose a reason for hiding this comment

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

Just noticed that this was not actually passed through.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.84 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.61 KB (+0.02% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.37 KB (0%)
@sentry/browser - Webpack (minified) 66.54 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.63 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.02% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.42 KB (-0.68% 🔽)
@sentry/replay - Webpack (gzipped + minified) 38.64 KB (-0.81% 🔽)

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.

Nice!

I think going with an integration test is a good thing in this case.

Base automatically changed from fn/replay-stop-on-error to master January 16, 2023 09:48
@mydea mydea marked this pull request as ready for review January 16, 2023 09:49
@mydea
Copy link
Member Author

mydea commented Jan 16, 2023

ref #6770 as either here or there we should adjust the integration test.

@mydea mydea merged commit 81ef0ca into master Jan 16, 2023
@mydea mydea deleted the fn/replay-error-response branch January 16, 2023 12:21
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

2 participants