What does status=canceled for a resource mean in Chrome Developer Tools?

前端 未结 30 1670
温柔的废话
温柔的废话 2020-11-22 11:13

What would cause a page to be canceled? I have a screenshot of the Chrome Developer Tools.

\"Canceled

相关标签:
30条回答
  • 2020-11-22 11:27

    If you make use of some Observable-based HTTP requests like those built-in in Angular (2+), then the HTTP request can be canceled when observable gets canceled (common thing when you're using RxJS 6 switchMap operator to combine the streams). In most cases it's enough to use mergeMap operator instead, if you want the request to complete.

    0 讨论(0)
  • 2020-11-22 11:27

    The requests might have been blocked by a tracking protection plugin.

    0 讨论(0)
  • 2020-11-22 11:28

    For me 'canceled' status was because the file did not exist. Strange why chrome does not show 404.

    0 讨论(0)
  • 2020-11-22 11:28

    In my case, it started coming after chrome 76 update.

    Due to some issue in my JS code, window.location was getting updated multiple times which resulted in canceling previous request. Although the issue was present from before, chrome started cancelling request after update to version 76.

    0 讨论(0)
  • 2020-11-22 11:29

    We fought a similar problem where Chrome was canceling requests to load things within frames or iframes, but only intermittently and it seemed dependent on the computer and/or the speed of the internet connection.

    This information is a few months out of date, but I built Chromium from scratch, dug through the source to find all the places where requests could get cancelled, and slapped breakpoints on all of them to debug. From memory, the only places where Chrome will cancel a request:

    • The DOM element that caused the request to be made got deleted (i.e. an IMG is being loaded, but before the load happened, you deleted the IMG node)
    • You did something that made loading the data unnecessary. (i.e. you started loading a iframe, then changed the src or overwrite the contents)
    • There are lots of requests going to the same server, and a network problem on earlier requests showed that subsequent requests weren't going to work (DNS lookup error, earlier (same) request resulted e.g. HTTP 400 error code, etc)

    In our case we finally traced it down to one frame trying to append HTML to another frame, that sometimes happened before the destination frame even loaded. Once you touch the contents of an iframe, it can no longer load the resource into it (how would it know where to put it?) so it cancels the request.

    0 讨论(0)
  • 2020-11-22 11:29

    One the reasons could be that the XMLHttpRequest.abort() was called somewhere in the code, in this case, the request will have the cancelled status in the Chrome Developer tools Network tab.

    0 讨论(0)
提交回复
热议问题