react-polling icon indicating copy to clipboard operation
react-polling copied to clipboard

Polling empty responses?

Open asgeirn opened this issue 5 years ago • 3 comments

https://github.com/vivek12345/react-polling/blob/6a807c2b535aace01b342c7ee627c8f61d970c4e/src/ReactPolling.js#L127

I'm attempting to use the component for an asynchronous REST service, where the /status endpoint will respond with 202 and an empty response body until the service eventually succeeds.

However, since the response function evaluates Body.json(), I'm suspecting the polling stops on an unhandled error. Perhaps the function should guard with a test for non-empty body before evaluating Body.json()?

asgeirn avatar Nov 26 '19 08:11 asgeirn

I am also facing this issue, I am receiving plain text response from an API successfully, but the library is considering it as failure. It triggers onFailure after receiving the success response 200.

qtcoder999 avatar Mar 25 '20 09:03 qtcoder999

Hey @asgeirn and @qtcoder999 , apologies for the delay. The last couple of months have been really hectic in terms of work. But I am hoping latest release v1.0.7 will address all your concerns. Thank you for creating this issue and I hope the new release is helpful.

Please try it and let me know if it fixes your issue.

vivek12345 avatar Jun 23 '20 01:06 vivek12345

Hi,

I've just tested v1.0.8, but unfortunately this didn't work for our case. We've worked around it with a fork where we've added the following :

          if (resp.headers.get('Content-Length') === '0') {
            if (resp.ok) {
              return resp;
            } else {
              return Promise.reject({ status: resp.status, resp });
            }
          }

asgeirn avatar Sep 09 '20 11:09 asgeirn