6

Good afternoon,

Witnessing strange behavior today in the browser's developer console when logging objects and arrays from my lightning web component. All objects and arrays are being logged as "Proxy {}", is this consistent for other developers?

Code snippet:

propertyObj = { t1: 'hello', t2: 'world' };
propertyArr = [1, 2, 3, 4];

@track myProxy = { p1: 'test', p2: 44 };            // Should be the only item that is proxied

connectedCallback(){
    console.log(this.propertyObj);                  // Should not be proxied
    console.log(this.propertyArr);                  // Also should not be proxied

    console.log(this.myProxy);                      // Is proxied as expected

    // Define object
    var obj = {prop1: 'xyz', prop2: 'abc'};
    console.log(obj);                               // Outputs to console as proxy, should NOT be proxied
    console.log(JSON.parse(JSON.stringify(obj)));   // Useful trick but also does not work to convert from proxy to object

    // Define array
    var arr = [22, 33, 44];
    console.log(arr);                               // Outputs to console as proxy, should NOT be proxied
}

However, the console will display the actual objects and arrays when "Debug Mode" is enabled for my org's user - this was not necessary before.

Additionally, this same code will not be proxied when it is run on a different org that was created from Trailhead one year ago. Note: Both orgs are on the same Salesforce release and are each on Lightning Locker API version 55.0.

Browser: Chrome

Developer Console Settings: enter image description here

Are you experiencing this behavior on your org as well?

Thanks


Update 2022-09-14

Tested same code in Edge and the items are not proxied (with exception to myProxy, this is expected). This leaves me inclined to believe it is a Chrome issue - my version is 105.0.5195.127 (Official Build) (64-bit).

4
  • 2
    There was a release window on September 9th, 2022. Are you sure the newer org isn't on Winter '23? If I had to guess, they did something to patch the latest version. Try creating two scratch orgs, one in Summer '22, and one in Winter '23, deploy the code to both, and see if there's a difference in behavior.
    – sfdcfox
    Commented Sep 12, 2022 at 19:11
  • 2
    @Blake the different behavior may be related to lighting web security. under session settings, check if lightning web security is enabled
    – Shamina
    Commented Sep 12, 2022 at 19:43
  • Hey @Shamina thanks for your input. The org in question did have this security setting enabled (the old one did not). I have now disabled that option, however, the issue still remains.
    – Blake
    Commented Sep 12, 2022 at 21:17
  • Thanks for the reply @sfdcfox , I verified both orgs are on Summer '22. I created a new org on Winter '23 Patch 5.6 and observed the same behavior with the proxies as the org on Summer '22 Patch 18.6. Is this behavior consistent with your org? I went to status.salesforce.com/instances/<your org instance from Company Information> to check my org version if you would like to compare.
    – Blake
    Commented Sep 12, 2022 at 21:34

1 Answer 1

4

my solution that appeared to fix the problem:

You must also have “Use Lightning Web Security for Lightning web components” disabled in your org for this method

  • Setup > Session Settings > Uncheck “Use Lightning Web Security for Lightning web components”

Then use console.log(JSON.parse(JSON.stringify(myObj))) to view the proxy.

Note: On my end I had to modify the file (added a single character), then redeployed, and my console was back to working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .