test(replay): Test compressed recording payloads#7082
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.
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.
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.
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.
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 📦
|
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.jsfile changed. Before this PR we already usedpako@2.1.0for the worker and the only thing I did was addingpakoto theintegration-testspackage. Regardless, I think this should be finedepends on #7052
ref #7044