Undici throwing error when parsing empty response with application/json content type #3348
-
Hey! So possibly dumb question. Undici is throwing an error when it tries to parse the response of a PUT request in our integration environment. The response body is empty & the response headers have ERROR Unexpected end of JSON input
│ SyntaxError: Unexpected end of JSON input
│ at JSON.parse (<anonymous>)
│ at parseJSONFromBytes (node:internal/deps/undici/undici:5329:19)
│ at successSteps (node:internal/deps/undici/undici:5300:27)
│ at fullyReadBody (node:internal/deps/undici/undici:1447:9)
│ at processTicksAndRejections (node:internal/process/task_queues:95:5)
│ at specConsumeBody (node:internal/deps/undici/undici:5309:7)
│ at Module.tsRestFetchApi I'm mostly looking for confirmation so that I can advocate for removing the content type from the empty response bodies. Just don't want to lead anyone in the wrong direction if not. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
A JSON is at least 2 bytes according to RFC 8259. The behavior of undici is correct. |
Beta Was this translation helpful? Give feedback.
A JSON is at least 2 bytes according to RFC 8259. The behavior of undici is correct.