I have a lwc component, used on internal platform app and experience site, which listens to platform event. We use empApi to subscribe to platform events when user is internal and cometD library to subscribe when user is experience site user. This component stopped working for experience site users after we enabled Lightning Web Security in our org. We are getting below error
Error occurred initializing/configuring cometD Error: Lightning Web Security: Cannot create Worker with blob:https://ascapone--ashishdev.sandbox.my.site.com/b1b66214-97c6-4ac2-9b82-29456a499cda
Going through the error log, I can see the error is thrown at some point duing cometD.configure function execution.
//This function subscribes to the channel using the cometD library
initializeCometD(sessionId) {
try {
if (this.cometDInitialized) {
return;
}
this.cometDInitialized = true;
let cometD = new window.org.cometd.CometD();
cometD.configure({
url: window.location.protocol + '//' + window.location.hostname + '/cometd/58.0/',
requestHeaders: { Authorization: 'Bearer ' + sessionId },
appendMessageTypeToURL: false,
logLevel: 'debug'
});
cometD.websocketEnabled = false;
cometD.handshake(status => {
if (status.successful) {
//console.log('Status ', status);
cometD.subscribe(CHANNEL_NAME, this.handleEvent);
if (this.enableTimer) {
this.getTimeOutValueAndEnableTimer();
}
} else {
console.error('Error in handshaking: ' + JSON.stringify(status));
}
});
} catch (error) {
if (this.enableTimer) {
this.getTimeOutValueAndEnableTimer();
}
console.error('Error occurred initializing/configuring cometD', error);
}
}