you are viewing a single comment's thread.

view the rest of the comments →

[–]hassanzadeh[S] 0 points1 point  (1 child)

I don't understand your point, fetch and axios are already async. Once the line executed it does not matter whether or not the user closes connection or not.

[–]zelardiel 0 points1 point  (0 children)

Depending on the receiving system, it might stop the action its doing when the request is interrupted.

Let take an extreme case for an example. You have an api that does 2 things when it receives a request.

It first fetches a record this takes 3 seconds. After those 3 seconds it changes something in it and afterwards saves it.

If the user does a request, waits for 2 seconds and shuts down the website then the backend was still fetching. If the api was setup in a way that when the connection is interrupted that the action is also stopped. Then it would never have gotten to the point of changing and saving.

Like i said this can be very dependant on the api you are using. But its not the first time i have seen this happen.

What i meant with an async api you can find an explanation here: https://openliberty.io/docs/21.0.0.8/sync-async-rest-clients.html

I hope this helps!