Closed Bug 1578138 Opened 5 years ago Closed 5 years ago

Investigate messages displayed twice

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(firefox72 fixed)

RESOLVED FIXED
Firefox 72
Tracking Status
firefox72 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

Details

Attachments

(1 file)

Sometimes some messages are displayed twice in the output.
We should check where this is coming from.

Whiteboard: dt-fission

This isn't fission related.

I have a sort of STR that seems to work most of the time:

  1. Start Firefox and navigate to data:text/html,<meta charset=utf8><script>var i = 0; setInterval(() => i < 40 && console.log(++i), 50)</script>
  2. Then close Firefox
  3. From the command line, run ./mach run -P dev --devtools, where dev is the same profile as the one you used in 1.

This opens Firefox, with devtools open, on a page that emit a console.log every 50ms.
Now I can see some messages being duplicated.

Doing the following modifications:

diff --git a/devtools/client/webconsole/webconsole-connection-proxy.js b/devtools/client/webconsole/webconsole-connection-proxy.js
--- a/devtools/client/webconsole/webconsole-connection-proxy.js
+++ b/devtools/client/webconsole/webconsole-connection-proxy.js
@@ -192,7 +192,10 @@ class WebConsoleConnectionProxy {
       );
     }
 
-    return response.messages;
+    return response.messages.map(message => ({
+      ...message,
+      prefix: "[CACHE]",
+    }));
   }

I prefix the messages coming from the cache with [CACHE].
And here's an example of output I get:

14 
15 
16 
17 
[CACHE]: 1 
[CACHE]: 2 
[CACHE]: 3 
[CACHE]: 4 
[CACHE]: 5 
[CACHE]: 6 
[CACHE]: 7 
[CACHE]: 8 
[CACHE]: 9 
[CACHE]: 10 
[CACHE]: 11 
[CACHE]: 12 
[CACHE]: 13 
[CACHE]: 14 
[CACHE]: 15 
[CACHE]: 16 
[CACHE]: 17 
18 
19 
20 
…

So we can see 4 messages (14, 15, 16, 17) appearing first, then the cached messages, which also contain those messages.
Looking at the code where we retrieve the cached messages, we can see that we first declare our Console API listener, and then retrieve the cached messages (devtools/client/webconsole/webconsole-connection-proxy.js#71,83).

We should probably do it the opposite way so we ensure to get the cached messages before the "live" ones (getting the cached messages also clears the cache).

No longer blocks: dt-fission-browser-console
Whiteboard: dt-fission

This patch ensures we get the cached messages
before setting the event listeners so we don't
risk having duplicated messages (coming from both
cache and event).

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Attachment #9104218 - Attachment description: Bug 1578138 - Retrieve cached messages before setting new messages event listeners. r=ochameau. → Bug 1578138 - Retrieve cached messages before setting new messages event listeners. r=honza.
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ff3dabd8559
Retrieve cached messages before setting new messages event listeners. r=Honza.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 72
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: