Investigate messages displayed twice
Categories
(DevTools :: Console, defect, P2)
Tracking
(firefox72 fixed)
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.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
This isn't fission related.
I have a sort of STR that seems to work most of the time:
- Start Firefox and navigate to
data:text/html,<meta charset=utf8><script>var i = 0; setInterval(() => i < 40 && console.log(++i), 50)</script>
- Then close Firefox
- From the command line, run
./mach run -P dev --devtools
, wheredev
is the same profile as the one you used in1.
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).
Assignee | ||
Comment 2•5 years ago
|
||
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 | ||
Updated•5 years ago
|
Updated•5 years ago
|
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9ff3dabd8559 Retrieve cached messages before setting new messages event listeners. r=Honza.
Comment 4•5 years ago
|
||
bugherder |
Description
•