Closed Bug 1214400 Opened 9 years ago Closed 8 years ago

Returned values and console.log messages appear out of order

Categories

(DevTools :: Console, defect)

43 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1044365

People

(Reporter: callahad, Unassigned)

Details

(Keywords: DevAdvocacy, Whiteboard: [polish-backlog][devtools-ux][difficulty=easy])

STR:

1. Open Console
2. Paste the following: function x() { console.log("Foo"); return "Bar" }
3. Run x();

The console should show:

    » x()
      Foo
    ← "Bar"

The console actually shows:

    » x()
    ← "Bar"
      Foo

This makes it look like somehow the function returned, and *then* the console.log fired. While usually not a problem with small, synchronous examples, this is *maddening* when trying to teach how generators work, since it makes it look like the function keeps running after yielding.

Safari, Chrome, Opera, and IE/Edge all follow the expected behavior.
This behavior is controlled by _outputAfterNode / afterMessage:

https://dxr.mozilla.org/mozilla-central/source/devtools/client/webconsole/console-output.js#947
https://dxr.mozilla.org/mozilla-central/source/devtools/client/webconsole/webconsole.js#3322

In short, we are intentionally putting the result of an execution after the input.  This is illustrated clearly if you run this code:

function x() {
  console.log("Foo");
  debugger;
  return "Bar";
}

x();

Notice that "Foo" shows up while you are paused at the debugger, but once you resume execution, bar shows up above foo.  I'm not convinced this is good behavior though as you mention in the report.  And we should probably get rid of that feature and optionally somehow link the two together visually.  Like if you hover the 'output' node maybe the 'input' node could be highlighted too.
Whiteboard: [polish-backlog] → [polish-backlog][devtools-ux]
Whiteboard: [polish-backlog][devtools-ux] → [polish-backlog][devtools-ux][difficulty=easy]
This was fixed by Bug 1044365
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.