Closed Bug 1967785 Opened 8 months ago Closed 5 months ago

NetworkDecodedBodySizeMap can throw if called after destroy

Categories

(Remote Protocol :: WebDriver BiDi, defect, P3)

defect
Points:
1

Tracking

(firefox144 fixed)

RESOLVED FIXED
144 Branch
Tracking Status
firefox144 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

Details

(Whiteboard: [webdriver:m17][lang=js])

Attachments

(1 file)

In NetworkDecodedBodySizeMap.destroy, we nullify all the internal maps. But if for any reason we still call the NetworkDecodedBodySizeMap, we will then throw.

We should guard those methods to avoid JS errors.

Note that the NetworkDecodedBodySizeMap is destroyed from network module's destroy() method at https://searchfox.org/mozilla-central/rev/dbef1a2f75798fb0136b7428d959c8feb09ad5d1/remote/webdriver-bidi/modules/root/network.sys.mjs#357.
We already remove all event listeners in the network module itself, but that doesn't apply to the current NetworkEventRecord instances, which are still listening to their own error/stop events https://searchfox.org/mozilla-central/rev/dbef1a2f75798fb0136b7428d959c8feb09ad5d1/remote/shared/listeners/NetworkEventRecord.sys.mjs#71-72

At this point it means the session is already being destroyed, so the main side effect of those errors is log pollution.

Mentor: jdescottes
Severity: -- → S3
Points: --- → 2
Keywords: good-first-bug
Priority: -- → P3
Whiteboard: [webdriver:backlog][lang=js]

Note that an easy way to address this would be to simply reset the two maps to new Map in the destroy, instead of nullifying them.

Hey Julian Descottes, I have a fix for this but I'm having trouble figuring out how to manually test my changes. Do you have any tips?

Hi Anthony!

(In reply to Anthony Mclamb from comment #2)

Hey Julian Descottes, I have a fix for this but I'm having trouble figuring out how to manually test my changes. Do you have any tips?

We have a test for this class at https://searchfox.org/mozilla-central/source/remote/shared/test/xpcshell/test_NetworkDecodedBodySizeMap.js#1
You can run it using

./mach test remote/shared/test/xpcshell/test_NetworkDecodedBodySizeMap.js

As you can see in this test the last step is to call destroy(), you can try to call all of the APIs after that getDecodedBodySize, setDecodedBodySize and setAuthenticationAttemptMapping and at least check that they don't throw.

Flags: needinfo?(adylanmclamb)

Also taking this, too much log pollution on real websites.

Mentor: jdescottes
Points: 2 → 1
Keywords: good-first-bug
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/678e86bb258c https://hg.mozilla.org/integration/autoland/rev/635eae74e96a [bidi] Avoid log pollution from NetworkDecodedBodySizeMap r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 144 Branch
Whiteboard: [webdriver:backlog][lang=js] → [webdriver:m17][lang=js]
Flags: needinfo?(adylanmclamb)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: