New issue
Advanced search Search tips

Issue 785457 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Console Log is not point in time accurate

Reported by brian.bu...@gmail.com, Nov 15 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36

Steps to reproduce the problem:
1. Create an object setting a property to empty array.
2. console.log that object
3. update the property with values

What is the expected behavior?
should log an empty array.

What went wrong?
Shows the values for the next line of code.

Did this work before? N/A 

Chrome version: 62.0.3202.94  Channel: stable
OS Version: 10.0
Flash Version: 

A dev needs to be able to trust their tools.
 

Comment 1 by l...@chromium.org, Nov 15 2017

Cc: l...@chromium.org
Labels: Needs-Feedback
Thanks for the report.  I'd like to confirm steps to reproduce:
1) evaluate:
var x = {arr: []};
console.log(x);     // This logs an object to the console, collapsed, showing text `{arr: Array(0)}`

2) evaluate:
x.arr.push('foo')

3) Expand the object previously logged, and see
> {arr: Array(0)}
  > arr: ["foo"]
  >_proto__: Object

If these are your bug reproduction steps, are you referring to the fact that DevTools shows "Array(0)" while its "arr" property is not length 0?
evaluatedJustNow.png
30.3 KB View Download
Labels: Needs-Triage-M62
Seems similar enough.   Did it reproduce?
Project Member

Comment 4 by sheriffbot@chromium.org, Nov 16 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "luoe@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 5 by l...@chromium.org, Nov 16 2017

Status: WontFix (was: Unconfirmed)
I'm able to reproduce the mismatch between the preview of the object
`V {arr: Array(0)}`

and its property
`  > arr: ["foo"]`

If this is the behavior you are referring to, unfortunately this is intended behavior.  Whenever console.log() is called, a preview of the logged object is generated and logged to the console synchronously.  Property values seen in that preview are a snapshot in time.

However, when you expand an object in the console by clicking the triangle, DevTools retrieves the object's properties `at the time when you clicked expand`.  Properties at this time might be completely different than the properties at the time when the object was logged.

There are several other bugs that discuss this mismatch between logged-time and expanded-time properties here
https://bugs.chromium.org/p/chromium/issues/detail?id=50316

Please feel free to comment if you have further questions.

Sign in to add a comment