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

前端 未结 30 2188
温柔的废话
温柔的废话 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: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.

提交回复
热议问题