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

fix(readRawBody): handle body as object #403

Merged
merged 2 commits into from
Jun 20, 2023
Merged

Conversation

igorjacauna
Copy link
Contributor

Based in on this where seems unenv already parsed the body to Object and when try to create a Buffer from it, in nitro Firebase preset, throw a error mentioned here

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object

This change check if body is a Object and converts to string before create a Buffer from it

test/body.test.ts Outdated Show resolved Hide resolved
@Atinux Atinux requested a review from pi0 June 12, 2023 18:01
@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #403 (3703b63) into main (6fd36cf) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
+ Coverage   76.21%   76.26%   +0.05%     
==========================================
  Files          26       26              
  Lines        2438     2444       +6     
  Branches      339      341       +2     
==========================================
+ Hits         1858     1864       +6     
  Misses        580      580              
Impacted Files Coverage Δ
src/utils/body.ts 93.12% <100.00%> (+0.32%) ⬆️

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM!

BTW this is something we probably have to resolve in nitro presets to make sure provided body is a stream...

@pi0 pi0 merged commit add032a into unjs:main Jun 20, 2023
3 checks passed
@igorjacauna igorjacauna deleted the fix-read-raw-body branch June 21, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants