Closed Bug 1061278 Opened 10 years ago Closed 10 years ago

console.log is asynchronous

Categories

(DevTools :: Console, defect)

30 Branch
x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 754861

People

(Reporter: nick, Unassigned)

References

()

Details

So if I have a block of code like:

```javascript
var worker = new Worker('whatever.js');
var xhr = new XMLHttpRequest;
xhr.open('GET', 'whatever.txt');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
  console.log(xhr.response);
  worker.postMessage(xhr.response, [xhr.response]);
  console.log(xhr.response);
};
xhr.send();
```

I would expect the first logged ArrayBuffer to have a byteLength of whatever.txt, and the second logged Array buffer to have a byteLength property of 0.  Instead both are 0.  How is it zero before I invoke postMessage?
console.log works asynchronously.  You can see this trivially with a testcase like this:

  var obj = { a: 5 };
  console.log(obj);
  obj.a = 6;
Component: JavaScript Engine → Developer Tools: Console
Product: Core → Firefox
Also, note that the behavior was added pretty purposefully.
Summary: Transferrable Objects cleared too soon? → console.log is asynchronous
(In reply to Boris Zbarsky [:bz] from comment #2)
> Also, note that the behavior was added pretty purposefully.

So is this bug a non issue?
I would say it's a known issue (bug 754861). Fixing this would likely make games and other apps that use console.log in a tight loop appear very slow in Firefox. I don't have enough data to have an informed opinion on which is more important. I'll see if our product folks do.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Couldn't we take the performance hit only when the developer tools are being used?
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.