alexandernst
alexandernst

Reputation: 15099

Chrome dev tools (network tab) doesn't reflect aborted requests

I'm playing around with AbortController in order to cancel requests made with fetch. When I call abort() I do see my catch() handler being called (which means that the request was effectively canceled), but the request itself still retrieves the data from the endpoint (according to Chrome's network tab).

I was expecting the request to be aborted so that no download traffic would occur (assuming that the download of the actual data hasn't happened at the time the abort() is called).

Is this the expected behavior of AbortController?

As a side question: If "yes, that is the expected behavior, the request isn't aborted in a way to prevent download traffic", is there a way to actually abort a request made with fetch?

Edit: I'm testing https://fetch-abort-demo.glitch.me with Chrome and Safari, and while Safari does highlight with red the aborted request, Chrome doesn't. Maybe this is just a Chrome UI bug?

Upvotes: 3

Views: 1183

Answers (1)

Tschallacka
Tschallacka

Reputation: 28742

Yes, that is expected behaviour.

Say you say to me, give me all the nuts from that bag behind you.

I hand you all the nuts scoop by scoop in the bag you are having. Having been halfway finished emptying my bag into yours, you change your mind, drop the bag on the floor and walk away without saying a word.

Are there still nuts in what was once your bag? Yes, because it takes time to transfer data, and data is delivered in chunks/packets, piece by piece. Only when all the packets are transferred is the transmission complete.

Your request was aborted, but it had been in progress for a while getting packets. You just stopped requesting and accepting packets.

Upvotes: 1

Related Questions