1

Due to some recent changes, first:

  • Enabling by default Use Lightning Web Security for Lightning web components
  • Enable Stricter Content Security Policy

it becomes impossible to debug LWC Javascript files since even you put debugger statement inside, it never stops in Chrome Debugger tools.

I tried to use Grzegorz Skaruz and Sara Morgan suggestions to include "lockerServiceNext": false settings in scratch org definition settings like following:

{
    "orgName": "Development Manual",
    "edition": "Developer",
    "features": [],
    "language": "en_US",
    "settings": {
        "securitySettings": {
            "sessionSettings:": {
                "lockerServiceNext": false
            }
        }
    }
}

However, when I try to create a scratch org using these settings, I receive the following error:

Error (1): A scratch org was created with username [email protected], but the settings failed to deploy due to: Error parsing file: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

Also, I think that I really need to include

    "securitySettings": {
        "sessionSettings:": {
            "lockerServiceCSP": false
        }
    }

but any of configuration fail with the same error

Error (1): A scratch org was created with username [email protected], but the settings failed to deploy due to: Error parsing file: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

Is there any workaround or fix to this problem?

6
  • 4
    Turning off LWS isn't necessarily a fix--it will be enabled everywhere eventually when LS is retired. A root cause analysis should be done in order to report the bug to salesforce.com. I'll take a look at it over the weekend and see if I can find something. Commented Apr 14, 2023 at 14:17
  • well, maybe it is not a fix, but the only available workaround at the moment, and my question is more about how to enable that workaround, not really about what the workaround is Commented Apr 14, 2023 at 14:21
  • @sfdcfox there is a different question which asks actually what is the fix or workaround salesforce.stackexchange.com/questions/380016/… and disabling LWS is an accepted answer there Commented Apr 14, 2023 at 14:22
  • For what it's worth, I'm debugging more or less just fine in my sandboxes with LWS turned on, but only when Debug Mode is also enabled. The only annoyance seems to be that sometimes the source map is one line off, which makes it more of a challenge, but I don't think I've encountered this particular bug in an org. Commented Apr 14, 2023 at 15:14
  • debug mode sometitmes make really hard to debug since pages become non-responsive. Have you tried without a debug mode? Commented Apr 15, 2023 at 11:49

1 Answer 1

3

Looks like the only option here is to create a file force-app/main/default/settings/Security.settings-meta.xml with the following body

<?xml version="1.0" encoding="UTF-8"?>
<SecuritySettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <sessionSettings>
        <lockerServiceCSP>false</lockerServiceCSP>
    </sessionSettings>
</SecuritySettings>

or

<?xml version="1.0" encoding="UTF-8"?>
<SecuritySettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <sessionSettings>
        <lockerServiceNext>false</lockerServiceNext>
    </sessionSettings>
</SecuritySettings>

and perform push or deploy

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.