Skip to content

test(replay): Test compressed recording payloads #7082

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

Merged
merged 3 commits into from
Feb 8, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Feb 7, 2023

This PR adds the Playwright integration test utilities to test Replay's compression. We now have a dedicated parser that attempts to decompress a payload, if it encounters a zlib-compressed replay recording payload. Took me quite a while to figure out how this works and admittedly, the solution I came up with is a bit hacky (see code).

Additionally, this PR adds a simple test to check that an initial full compressed snapshot has the correct content.

Note: Not sure why the worker.js file changed. Before this PR we already used [email protected] for the worker and the only thing I did was adding pako to the integration-tests package. Regardless, I think this should be fine

depends on #7052

ref #7044

const envelopeBytes = request?.postDataBuffer() || '';

// first, we convert the bugger to string to split and go through the uncompressed lines
const envelopeString = envelopeBytes.toString();
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we'll hit some string encoding issues -- does this need to be utf8? I guess easy way to test this is to add some unicode to our tests :)

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. I added it to the improvement issue. I'm gonna tackle this separately to not widen the scope of this PR.

Comment on lines +154 to +160
// If we fail to parse a line, we _might_ have found a compressed payload,
// so let's check if this is actually the case.
// This is quite hacky but we can't go through `line` because the prior operations
// seem to have altered its binary content. Hence, we take the raw envelope and
// look up the place where the zlib compression header(0x78 0x9c) starts
for (let i = 0; i < envelopeBytes.length; i++) {
if (envelopeBytes[i] === 0x78 && envelopeBytes[i + 1] === 0x9c) {
Copy link
Member

Choose a reason for hiding this comment

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

Yikes, wish we had added some additional headers to determine the payload type. I wouldn't have expected split to change the binary content though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, that would have been a good idea 😅 I think it's not so much the split as rather the toString call beforehand. My pragmatic take here: Let's leave it as is for now and if (when) it bites us in the back, we'll revisit.

Base automatically changed from lms-replay-playwright-recording-tests to develop February 8, 2023 07:53
@Lms24 Lms24 force-pushed the lms-replay-pw-compression branch from 6fd1984 to 2f2ab9c Compare February 8, 2023 12:40
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.06 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 62.19 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.69 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55.33 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.42 KB (0%)
@sentry/browser - Webpack (minified) 66.77 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.45 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.74 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.97 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.23 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.88 KB (+0.06% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.79 KB (+0.09% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.6 KB (+0.05% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 55.13 KB (added)

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.

very nice!

@Lms24 Lms24 marked this pull request as ready for review February 8, 2023 13:24
@Lms24 Lms24 merged commit f4564cc into develop Feb 8, 2023
@Lms24 Lms24 deleted the lms-replay-pw-compression branch February 8, 2023 13:26
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.

3 participants