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

Feature Request: Allow Recordings to be Saved Decoded and Unzipped #463

Open
Justintime50 opened this issue May 16, 2022 · 4 comments
Open

Comments

@Justintime50
Copy link

Justintime50 commented May 16, 2022

Description

Per the comment made here: #265 (comment), it was suggested that adding the ability to allow recordings to be saved decoded and unzipped could be added to Pollyjs. We have open sourced various client libraries across 7 languages, each with its own "VCR" solution like Polly, each allowing for the recordings to be unzipped and decoded for manual inspection which is important to us. At present, we'd have to setup a lot of boilerplate code via beforePersist to get Polly to decode/unzip all requests/responses when this is an ideal first class feature of Polly itself so that engineers can ensure the responses look like what we expect in a human readable fashion like we can using other language VCR solutions.

For our purposes, we needed to ensure it takes chunked responses into account as well and concatenated each chunk, decompressed them, then turned them into storable strings for the recording file itself. We then reversed the process for beforeReplay.

@Josiassejod1
Copy link

I just discovered @Justintime50 that if you disable compression in your headers you can get it to work

getBodyFromChunks(chunks, headers) {

https://stackoverflow.com/questions/18398022/disable-gzip-compression-in-chrome

we shouldn't have to do that but its a temporary workaround

@Justintime50
Copy link
Author

Justintime50 commented Jun 1, 2022

@Josiassejod1 although that works, it's not ideal for our situation.

The code we are using to accomplish this can be found here: https://github.com/EasyPost/easypost-node/pull/253/files#diff-34ee99ca00f431605c35bbb1974fb5cad2c5cd3c076ff29165d24d490c619459 (the PR is large but the file you want is the cassette_encoding.js file. This link should take you there but may take a second to load due to the PR size)

@Josiassejod1
Copy link

I feel you on that @Justintime50 would rather this be an option that can be toggled

@andreynering
Copy link

I think this would be useful as well. For comparison the vcr gem in the Ruby world does this.

The reason is that it allows us to easily see what is really being requested and responded.

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

No branches or pull requests

3 participants