Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I'm trying to use web workers in lightning component. Using them in lightning component directly fails due to LockerService. Another option of using them inside the newly available lightning: container fails due to CSP rules. Don't know if it matters but I'm using a patch org and developing a managed packed.

The issue I'm getting is:

Refused to create a worker from 'blob:' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension: * 'nonce-yyyy'". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.

I've created a manifest.json file inside the resource with the following content according to the following documentation:


  "landing-pages" : [


      "path": "index.html",

      "content-security-policy-type": "custom",

      "content-security-policy": "script-src *;"




It seems that my manifest.json is being ignored. Here is the CSP request that is being sent:

{"csp-report":{"document-uri":"","referrer":"","violated-directive":"worker-src","effective-directive":"worker-src","original-policy":"default-src 'self'; script-src  'self' chrome-extension: * 'nonce-yyyy'; object-src 'self'; style-src 'self' chrome-extension: 'unsafe-inline' *; img-src 'self' http: https: data: blob: *; media-src 'self' *; frame-ancestors; frame-src https: mailto: *; font-src 'self' https: data: *; connect-src 'self' *; report-uri /_/csp","disposition":"enforce","blocked-uri":"blob","line-number":1,"column-number":31921,"source-file":"","status-code":0,"script-sample":""}}

I would like to get Web Workers working in SalesForce lightning component, one way or another. Anyone had similar situation?

1 Answer

0 votes
by (26.7k points)
edited by

Webassembly are blocked in Locker service as because if it is allowed, then it is upto salesforce which can guarantee that it should not violate the security rules which is enforced by Locker Service. But, you can use lightning container instead of using Visualforce. Lightning container allows you to create components that can be used in a safe manner in a lightning context.

I hope this will work.

Want to become a Salesforce expert? join this Salesforce Course Online now!!

Browse Categories