I am testing out a cross-origin web request. I find that in Chrome, most of the time the preflight OPTION request comes after the actual GET request. This is the order as seen in the Network tab of Chrome Developer Tools.
Shouldn't the OPTION response be first received by the browser before it can decide whether to send the GET request?
The start time (or initiation time) of a request corresponds, not to the moment the browser actually sends the request, but to the moment the browser initiates the request.
According to Chrome's documentation,
By default, the requests in the Requests table are sorted by initiation time [and in ascending order].
But initiation time does not correspond to the moment when the browser actually sends the request! From the browser's point of view, the actual request is initiated/started (if not sent) before the associated preflight request is.
You can view the browser as some intermediary between the client (which initiates the actual request) and the server. The diagram below (borrowed from elsewhere) illustrates the ordering of the preflight and actual requests:
You can see that
fetch('https://www.example.com', {method: "PUT"})