Home > Back-end >  Is it possible for an API to do backend work but I don't get the response?
Is it possible for an API to do backend work but I don't get the response?

Time:03-22

Let's say that while the API doing the work on backend, the http request consumer got disconnected. Therefore, database is updated but the consumer application doesn't know about it.

Is this scenario possible?

How can such a case be tested?

CodePudding user response:

I think it is certainly a possibility.

The first thing I would try is to make the client-expected response from the API nothing in order to simulate such a scenario.

CodePudding user response:

Yes, it's possible and common, your client need consider this situation. Also that's one of the reasons to use RESTful API, because it is stateless.

There's several ways to simulate such a scenario, one of them could be to put a sleep timer on your backend method so you manually disconnect or close the client, or it may reach timeout as well.

  • Related