-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
const envelopeBytes = request?.postDataBuffer() || ''; | ||
|
||
// first, we convert the bugger to string to split and go through the uncompressed lines | ||
const envelopeString = envelopeBytes.toString(); |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
// 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
6fd1984
to
2f2ab9c
Compare
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice!
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 addingpako
to theintegration-tests
package. Regardless, I think this should be finedepends on #7052
ref #7044