Skip to content

Conversation

@Aeolun
Copy link

@Aeolun Aeolun commented Jun 17, 2025

I'm still trying to figure out how it happens (something involving tRPC responses), but for now I'll be happy if I can stop compress from trying to compress something it can't.

I assume the differing behavior between the automatic compression (hook), and manual compression (the compress function) is because you don't want to mess with payloads (e.g. serialize them) unless people explicitly call the compress function. I've kept that behavior, and the global hook simply doesn't compress if it gets something it cannot deal with, while the compress function, well, it already serialized things, so it might cause wonky behavior if you pass it a Response object.

Tests:

  • Test that Response objects are not compressed on global hook
  • Test that objects get serialized normally when using compress
  • Test that Response objects are compressed after being serialized to {} with the compress function.

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Can you please add a unit test?

@Aeolun Aeolun marked this pull request as ready for review June 18, 2025 03:10
@Aeolun Aeolun force-pushed the main branch 4 times, most recently from 599207e to e399f43 Compare June 18, 2025 04:00
…cannot

Sending something other than buffers of strings in the `payload` happens, but this would break the later `Buffer.byteLength(payload)`

Signed-off-by: Bart Riepe <[email protected]>
@mcollina
Copy link
Member

Great work! Can you document this new option?

@Aeolun
Copy link
Author

Aeolun commented Jun 18, 2025

@mcollina I considered writing something about it, but I don't think this is something that you can really document? It doesn't so much change functionality so much as prevent a messy thrown error. I can add a gotcha or something at the end of the README.md?

@mcollina
Copy link
Member

@Aeolun yes. There is a new option passed as the config of the plugin, and that should be mentioned in the README.md

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.

2 participants