I found that fetch
API always throw TypeError
, ERR_EMPTY_REPONSE
or NetworkError when attempting to fetch resource
for 102
or any code smaller than 200
, regardless of the body of the response.
This took me tremendous time to figure out. Behavior is consistent amongst Fx, Chrome and Opera. I also confirmed that Postman correctly identifies the 102
response.
I wonder why is this happening? 1xx
code should be fine and it is not up to fetch
to decide whether it is an error. I can't find any document and can't seem to find anyone who is in the same situation.
Is this by design? Or are there anyway to get around this problem? I need 102
.
The Fetch spec requires browsers to follow the behavior described in the question. See specifically https://fetch.spec.whatwg.org/#ref-for-concept-response-status%E2%91%A0%E2%91%A8:
Any responses whose status is in the range
100
to199
, inclusive, and is not101
, are to be ignored.Note: These kind of responses are eventually followed by a "final" response.