devtools.network.onRequestFinished listener fires before HAR entry is fully populated
Categories
(DevTools :: Netmonitor, defect, P2)
Tracking
(firefox67 verified)
Tracking | Status | |
---|---|---|
firefox67 | --- | verified |
People
(Reporter: dharding, Assigned: antross)
References
Details
Attachments
(4 files)
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Reporter | ||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment 7•6 years ago
|
||
Comment 8•6 years ago
|
||
Comment 9•6 years ago
|
||
Comment 10•6 years ago
|
||
Reporter | ||
Comment 11•6 years ago
|
||
Assignee | ||
Comment 12•6 years ago
|
||
Assignee | ||
Comment 13•6 years ago
|
||
I got some time to look into this and think I've identified where the race condition is. I made a change which I confirmed resolved my repro locally with a custom build of Firefox. Tests still passed, though I could easily be missing some unintended side-effects of the change.
If this sounds good, let me know if you'd prefer to take it from here or if you'd like me to try submitting a patch. I may need some help introducing a reliable test to capture the race condition if that's desired.
Short version:
Trigger onRequestFinished
listeners in response to PAYLOAD_RECEIVED
instead of REQUEST_ADDED
:
https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/api.js#60
Long version:
The onRequestFinished
listeners are currently triggered in response to the internal REQUEST_ADDED
event. That event is fired when a request is initially added to the netmonitor - so the request may not have a response yet:
https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/connector/firefox-data-provider.js#99
Even though some response data is lazily requested from the backend by HarBuilder
(via requestData
in FirefoxDataProvider
), even that can return from the backend empty if the response hasn't completed yet (and simple items, such as status
, are not lazily requested anyway):
https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/har/har-builder.js#326
So REQUEST_ADDED
appears to fire too early to reliably include response data in onRequestFinished
. Looking at FirefoxDataProvider
, various aspects of a request payload get queued and eventually merged. When this is done, PAYLOAD_READY
fires (once per request according to the comment in onPayloadDataReceived
):
https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/connector/firefox-data-provider.js#427
The onPayloadDataReceived
handler that triggers PAYLOAD_READY
also includes comments indicating it fires when requestData
can be used, further suggesting this is the right event to wait for instead of REQUEST_ADDED
.
Reporter | ||
Comment 14•6 years ago
|
||
I'm happy to test once there is a patch available.
Assignee | ||
Comment 15•6 years ago
|
||
Honza, any thoughts on this?
Comment 16•6 years ago
|
||
(In reply to Tony Ross from comment #13)
I got some time to look into this and think I've identified where the race condition is. I made a change which I confirmed resolved my repro locally with a custom build of Firefox. Tests still passed, though I could easily be missing some unintended side-effects of the change.
If this sounds good, let me know if you'd prefer to take it from here or if you'd like me to try submitting a patch. I may need some help introducing a reliable test to capture the race condition if that's desired.
Short version:
Trigger
onRequestFinished
listeners in response toPAYLOAD_RECEIVED
instead ofREQUEST_ADDED
:
https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/api.js#60
This is great help, thanks for the analysis Tony!
Yes, this makes sense and it seems to be the problem. Note that when registering the listener for PAYLOAD_RECEIVED
(instead of REQUEST_ADDED
) you should also make sure that the right listener is unregistered in the destroy
method (in the same api.js file).
Please attach a patch, so people can test this.
Honza
Assignee | ||
Comment 17•6 years ago
|
||
Fire onRequestFinished after PAYLOAD_RECEIVED instead of REQUEST_ADDED.
Ensures response data is available for a request before dispatching the event.
Comment 18•6 years ago
|
||
Thanks Tony!
Push to our Try server (integration tests) looks good:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=1d71714f994a3a7383d0faccb2a0aafebd26640d
I'll be yet testing this manually.
Honza
Reporter | ||
Comment 19•6 years ago
|
||
Just tested Tony's patch using Firefox 65. Prior to applying the patch I could still consistently reproduce the issue. After rebuilding with the patch applied I have been unable to reproduce. Looks good to me - thanks Tony!
Comment 20•6 years ago
|
||
I just tested the patch as well (with and without) and I can't reproduce the issue if the patch is applied.
Great job here, thanks Tony!
Honza
Comment 21•6 years ago
|
||
Assignee | ||
Comment 22•6 years ago
|
||
Great to hear this is working for everyone - I'm glad I could help!
Comment 23•6 years ago
|
||
bugherder |
Updated•6 years ago
|
Updated•6 years ago
|
Comment 24•6 years ago
|
||
I've managed to load and use that addon via the about:debugging page.
However, there where still some results that appear to be with zero headings; this is the case for macOS10.13 (beta12)
Is it something of concern? Saw that the message was for the favicons or I might be wrong. Questions would be if it's safe to mark the bug as verified with this?
Attaching the log files for confirmation as well.
Thanks!
Updated•6 years ago
|
Assignee | ||
Comment 25•6 years ago
|
||
@Honza This still looks verified to me.
I confirmed the Network panel of the tools also does not display any response headers for the favicon requests on https://www.mozilla.org/en-US/privacy/firefox/.
My interpretation is this suggests the API is consistent with the Network panel so the fix is still valid. Whether or not response headers should be shown in the Network panel in the first place would be a separate issue (I'm guessing it relates to how favicons are fetched).
Comment 26•6 years ago
|
||
(In reply to Tony Ross [:antross] from comment #25)
I confirmed the Network panel of the tools also does not display any response headers for the favicon requests on https://www.mozilla.org/en-US/privacy/firefox/.
@antros: Thanks for the update! Can you please file a new bug for this and provide some instructions how to reproduce it? This bug report is already closed.
Honza
Assignee | ||
Comment 27•6 years ago
|
||
(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #26)
(In reply to Tony Ross [:antross] from comment #25)
I confirmed the Network panel of the tools also does not display any response headers for the favicon requests on https://www.mozilla.org/en-US/privacy/firefox/.
@antros: Thanks for the update! Can you please file a new bug for this and provide some instructions how to reproduce it? This bug report is already closed.
Honza
Looks like I lost the repro after my most recent update unfortunately (or fortunately depending on how you look at it). Not sure if it was tied to a specific version or was state-related, but if I manage to get a repro again I'll open a new bug.
Tony
Comment 28•6 years ago
|
||
Thanks a lot for this Tony! I've filed bug 1552686 for the onNavigated behaviour I mentioned in comment 3.
Comment 29•5 years ago
|
||
Closing issue as per comment 25.
Description
•