Skip to main content

Good morning,

 

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: 

Proxy on all Objects and Arrays logged in LWC - Salesforce

 

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).

답변 6개
  1. 2022년 9월 16일 오후 7:35

    Hi all, 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. 

     

    Strange issue, let me know if this solution helped you.

0/9000