-
Notifications
You must be signed in to change notification settings - Fork 541
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
Update chunksDecode #2855
Update chunksDecode #2855
Conversation
This looks wrong to me. But maybe someone else disagrees. |
This does not make any sense. Also why would we need to call JSON.stringify all the time as So why do we need here two double quotes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes no sense
Line 306: resolve(JSON.parse(chunksDecode(body, length))) |
We understand what you are trying to do and we don't think it's a good idea. If we try to decode an empty string we think it should error. |
Shouldn't it return at least 204 then? |
Who? The server? That's out of our control... |
If the person calls an external API they do not have control of the body. |
The problem is that you are not describing the error properly. Your bug report is actually: An endpoint returns an empty string as payload. Fetch against this endpoint is successful. Calling body.text() returns an empty string as expected. Calling body.json() returns in an error, because an empty string can not be parsed successfully. The question is, is throwing an error correct? |
I investigated this and this is definetly working as expected. |
Maybe just return body without parse it |
No. |
We follow the body mixin spec on this. Which is what our users expect. https://developer.mozilla.org/en-US/docs/Web/API/Request/json https://fetch.spec.whatwg.org/#ref-for-dom-body-json%E2%91%A0 |
From this bug: 2854