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 recording when hitting a rate limit #7018

Merged
merged 2 commits into from Feb 1, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Feb 1, 2023

As discussed and outlined in #6984, we want to entirely stop recording the replay once we receive a 429 rate limit response. This PR gets rid of all the "pause on rate limit" logic. Because we already stop when we receive other http error responses, we can simply use this logic instead.

Note: feat() over ref() because it's a behaviour change, not because handling rate limits is entirely new (#6710)

closes #6984

@Lms24 Lms24 requested review from mydea and billyvg February 1, 2023 11:18
@Lms24 Lms24 force-pushed the lms-replay-stop-on-ratelimit branch from d074416 to 4c2a170 Compare February 1, 2023 11:21
@@ -64,120 +64,9 @@ describe('Integration | rate-limiting behaviour', () => {
replay && replay.stop();
});

it.each([
Copy link
Member Author

Choose a reason for hiding this comment

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

IMO we don't need these tests anymore, as they only tested that we pause correctly for different rate limit timeouts we might receive from the Sentry backend. Just ensuring that we don't do anything after a 429 response should be good enough

Copy link
Member

Choose a reason for hiding this comment

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

Yes, makes sense! 👍 We could even move it to the general sendReplay tests I guess?

Copy link
Member Author

@Lms24 Lms24 Feb 1, 2023

Choose a reason for hiding this comment

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

Generally I think it makes sense but given that we have this neat comment under the last test,

// NOTE: If you add a test after the last one, make sure to adjust the test setup
// As this ends with a `stopped()` replay, which may prevent future tests from working
// Sadly, fixing this turned out to be much more annoying than expected, so leaving this warning here for now

and that I ran exactly into this problem, wasting 30minutes trying fix it, I'd vote we leave it as is.

Copy link
Member

Choose a reason for hiding this comment

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

ahh, right 🙈 damn we should fix those xD

@Lms24 Lms24 changed the title rfe(replay): Stop recording when hitting a rate limit ref(replay): Stop recording when hitting a rate limit Feb 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.88 KB (+0.02% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 61.57 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.54 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 54.88 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.29 KB (0%)
@sentry/browser - Webpack (minified) 66.37 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.31 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.6 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.79 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.08 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.79 KB (-0.85% 🔽)
@sentry/replay - Webpack (gzipped + minified) 38.7 KB (-0.5% 🔽)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.38 KB (-0.21% 🔽)

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

Nice, saving some bytes!

l: We may want to move the tests to the general send replay tests, I guess we don't need a separate test module then. but this is super unimportant. Thanks for tackling this! 👍

@mydea
Copy link
Member

mydea commented Feb 1, 2023

One comment: I guess this should be feat, not ref, as it kind of changes the behavior? WDYT?

@Lms24 Lms24 changed the title ref(replay): Stop recording when hitting a rate limit feat(replay): Stop recording when hitting a rate limit Feb 1, 2023
@Lms24 Lms24 merged commit 6ddc5cd into develop Feb 1, 2023
@Lms24 Lms24 deleted the lms-replay-stop-on-ratelimit branch February 1, 2023 16:25
mydea added a commit that referenced this pull request Nov 2, 2023
We changed this
[here](#7018), but
apparently it is possible to have responses with a 200 status code but
rate limit headers.

This PR updates our handling to stop either for a non-200 status code,
_or_ for a rate limit header.

I also streamlined the tests for this a bit, we were testing a bunch of
unrelated things, IMHO it's enough to test we stopped/didn't stop.

Resolves: getsentry/sentry#49498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop replay recording when hitting a rate limit
3 participants