Salesforce Breaking Javascript Console?

Problem Statement

I worked out a neat script to run in the Chrome DevTools console to make a configuration process faster. I went into my sandbox to reproduce the behavior so I could write it up in a Q&A post on here. Then I found something really strange and disturbing. It seems like Salesforce may have somehow disabled console output (at least in some sandboxes).

I did some digging and it looks like Facebook pioneered a strategy to disable the console. The basic gist of their approach is:

Object.defineProperty(console, '_commandLineAPI', { get : function() { throw 'Nope' } })

But that doesn’t seem to be what Salesforce is doing.


Observed Behavior

Here is how I normally expect the console to behave:

Standard Console Behavior

Here’s what it should look like after applying the hack:

Hacked Console Behavior

Here’s what it looks like in my sandbox:

Sandbox Console Behavior

The console does still seem to be logging system messages:

System Logging


Conclusions & Questions

There is no output. I’m at a loss to why it’s broken. I’ve searched around and most of the Stack Overflow posts (example) have to do with the filter settings, which clearly aren’t the cause of these missing logs. The log output isn’t being filtered out, it’s just completely swallowed somewhere.

I can also confirm this is not a browser issue, as I’m able to use DevTools normally everywhere else, even in a new tab on the same window. The behavior is consistent across the Home Page, Object Tabs, Detail Pages, and Visualforce Pages (except when showHeader="false"). The behavior presents on cs45 and cs19, but not test.salesforce.com or login.salesforce.com.

  • Why is my console broken?
  • How can I fix it?
  • Is Salesforce engineering this behavior?
  • Should I expect this behavior in production soon?

Update

Now seeing this information on na20 as well, so I also see it hitting production.

Answer

I think this issue is only affecting Chrome 52 and is related to this bug. https://bugs.chromium.org/p/chromium/issues/detail?id=636409

The workarounds for now are to use Chrome 53 (or greater) or another browser. Also, turning off the standard Salesforce header resolves this issue.

Attribution
Source : Link , Question Author : Adrian Larson , Answer Author : Jon Freed

Leave a Comment