nitro icon indicating copy to clipboard operation
nitro copied to clipboard

fix: encode buffer responses from cached event handler

Open harlan-zw opened this issue 2 years ago โ€ข 3 comments

๐Ÿ”— Linked issue

https://github.com/unjs/nitro/issues/1894

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [x] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Caching an endpoint that returns a buffer will break the endpoint. As an easy fix, we just base 64 encode whatever the result is and mark it as so.

๐Ÿ“ Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

harlan-zw avatar Nov 30 '23 08:11 harlan-zw

As of discussion in #1894, I think we might use raw methods of unstorage (behind a flag) also unstorage should automatically handle base64 transformation for drivers not supporting natively binary data if it does not it is something to fix there.

pi0 avatar Nov 30 '23 08:11 pi0

As of discussion in #1894, I think we might use raw methods of unstorage (behind a flag) also unstorage should automatically handle base64 transformation for drivers not supporting natively binary data if it does not it is something to fix there.

I agree, that seems like quite a bit of work though and I don't think I have enough context to attempt it.

Perhaps we can merge this as a temporary fix until that's ready? Not sure what else I can do to unblock myself with this bug.

harlan-zw avatar Nov 30 '23 10:11 harlan-zw

(was hoping to rebase with latest undio version to support at least all h3 binary types including streams. might delay to prioritize other reactors sorry for this delay it is an important issue)

pi0 avatar May 07 '24 18:05 pi0