Closed Bug 1719394 Opened 5 years ago Closed 1 month ago

Early WebSocket messages can be missing in the Network tab

Categories

(DevTools :: Netmonitor, defect, P3)

x86_64
Linux
defect

Tracking

(relnote-firefox 158+, firefox158 fixed)

VERIFIED FIXED
158 Branch
Tracking Status
relnote-firefox --- 158+
firefox158 --- fixed

People

(Reporter: holyfoek, Assigned: jstasiak)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-needed)

Attachments

(5 files, 2 external files)

Reproduction instructions

Keep this running in a terminal
docker run --rm --init -p 3030:3030 ekzhang/rustpad@sha256:728dd31070c027a5978008ac816164e2052462f9ad24c295e9d645ee2dc44134

Then visit
http://localhost:3030

Go to the devtools and activate the "Network" tab, filter for WebSocket requests, then refresh the page to see the requests.
Activate the WebSocket request and open the "Response" tab.

What happened?

Often (on my machine >50%), the first message is missing from the list.

What should have happened?

The first message should start with
{"Identity":

Anything else we should know?

Tested on 91.0a1 (2021-07-06) (64-bit) with a clean profile.

I believe the reason I could not reproduce this with the public instance of the server at https://rustpad.io is that the message has to arrive immediately after the connection is open for the message to be dropped.

Flags: needinfo?(odvarko)
Attached image image.png —

Thanks for the report, taso!

I can reproduce the problem using your Docker image on my Ubuntu (VM) machine.
See the attached screenshot. The first "identity" frame is missing.

Honza

Flags: needinfo?(odvarko)
Attached file websockets.php —

I am also attaching simpler test case that can be also used to repro the problem.

  1. Run the PHP script (WS server) locally on your machine
    php -q websockets.php

  2. Open DevTools and select the Network panel

  3. Load http://janodvarko.cz/tests/bugzilla/1719394/
    You can also load data URL: data:text/html,<script>new WebSocket('ws://127.0.0.1:12345/websockets.php');</script>

  4. Inspect WS frames for the 101 request

ER: You should see two frames: First Now <time> and (after two seconds) Second Now <time>
AR: The First Now frame is missing sometimes

You can also run the HTML client file locally on your machine (might be easier to repro the issue)

Honza

Severity: -- → S3
Status: UNCONFIRMED → NEW
Has STR: --- → yes
Ever confirmed: true
Priority: -- → P3

This bug makes debugging web socket connections in firefox unreliable, is there any workaround maybe?

Frames can be delivered before webSocketOpened reaches the DevTools
watcher. Carry the HTTP channel ID on every frame callback so those
frames can be associated immediately instead of being discarded.

Assignee: nobody → jakub+mozilla.org
Status: NEW → ASSIGNED

I have a patch (Phabricator revision attached) that I've been running for a few days and it seems to be working fine.

D320711 makes the HTTP channel ID available without consulting the
WebSocket connection map for frame notifications. Carry the ID on close
notifications as well so the DevTools watcher can remove that map.

Depends on D320711.

Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ff6a772594c7 https://hg.mozilla.org/integration/autoland/rev/0ba5a6dc2240 Preserve early WebSocket frames. r=devtools-reviewers,necko-reviewers,kershaw,jdescottes https://github.com/mozilla-firefox/firefox/commit/37266c1ac0e3 https://hg.mozilla.org/integration/autoland/rev/53e05637fde1 Remove WebSocket connection map. r=devtools-reviewers,necko-reviewers,jdescottes,kershaw
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1a81dc23e4c9 https://hg.mozilla.org/integration/autoland/rev/b59b5b8e456d Revert "Bug 1719394 - Remove WebSocket connection map. r=devtools-reviewers,necko-reviewers,jdescottes,kershaw" for causing dt failures @browser_net_ws-early-connection.js.

Backed out for causing dt failures @browser_net_ws-early-connection.js.

Flags: needinfo?(jakub+mozilla.org)
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/478de77eda46 https://hg.mozilla.org/mozilla-central/rev/cab028bbad37 Revert "Bug 1719394 - Remove WebSocket connection map. r=devtools-reviewers,necko-reviewers,jdescottes,kershaw" for causing dt failures @browser_net_ws-early-connection.js.
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch

Was backed out, should not be closed I think?

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8437595478a0 https://hg.mozilla.org/integration/autoland/rev/4be950c89eb3 Preserve early WebSocket frames. r=devtools-reviewers,necko-reviewers,kershaw,jdescottes https://github.com/mozilla-firefox/firefox/commit/9b6fd2c2d8ae https://hg.mozilla.org/integration/autoland/rev/8262f7bdd206 Remove WebSocket connection map. r=devtools-reviewers,necko-reviewers,jdescottes,kershaw
Status: REOPENED → RESOLVED
Closed: 1 month ago → 1 month ago
Resolution: --- → FIXED

Thanks for fixing this bug Jakub, glad it made it to mozilla-central this time!

Flags: needinfo?(jakub+mozilla.org)

Thank you for your help, it's much appreciated.

:jstasiak did you want to nominate this for 158 release notes?

Flags: needinfo?(jakub+mozilla.org)

Sure, let me know if this looks fine:

Release Note Request (optional, but appreciated)
[Why is this notable]: The Network Monitor could miss initial WebSocket messages if they arrived immediately after a connection was established.
[Affects Firefox for Android]: No
[Suggested wording]: Fixed an issue where the Network Monitor could miss WebSocket messages if they arrived immediately after a connection was established.
[Links (documentation, blog post, etc)]: N/A

Status: RESOLVED → VERIFIED
relnote-firefox: --- → ?
Flags: needinfo?(jakub+mozilla.org)
Keywords: dev-doc-needed
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: