Forum Discussion
Load React component inside power BI - Failed to construct 'Worker'
I'm working on rendering a react component inside power bi visual using bundle approach:
Here is how we are rendering the component(index.tsx):
Our React component depends on WASM files. We are able to load these WASM files by whitelisting the corresponding lib.js file, which is loaded as part of the Power BI custom visual.
However, we are explicitly passing an additional worker.js file to our React component which is rendered inside Component1. Power BI is blocking this worker script, resulting in the following error:SecurityError: Failed to construct 'Worker': Script at 'https://app.powerbi.com/****/*/worker.js' cannot be accessed from origin 'null'.
In this context, will Power BI allow loading a worker.js file specific to the React component, or is this scenario fundamentally restricted by Power BI’s sandboxing model?
Hi,
This behavior is expected due to the Power BI custom visual sandboxing model. Custom visuals run inside a sandboxed iframe with an opaque origin (origin = 'null'). Because of that, creating a Web Worker from a URL like https://app.powerbi.com/.../worker.js fails the browser’s origin checks, which is why you see:
Failed to construct 'Worker' ... cannot be accessed from origin 'null'
So to your question: loading a separate worker.js file by URL is effectively restricted in Power BI Service and isn’t something the visual can override.
Workable alternatives are:
Bundle the worker and create it via a Blob URL (or bundler-supported worker import), instead of loading worker.js as a hosted script.
If the worker is mainly for heavy compute, consider moving the processing outside the visual (backend/Fabric) or running the WASM on the main thread if feasible.
In short: Power BI is unlikely to allow externally loaded worker scripts, so the practical solution is to inline/bundle the worker rather than fetch it as a separate file.
4 Replies
- mohit_sakhareResolver II
Hi,
This behavior is expected due to the Power BI custom visual sandboxing model. Custom visuals run inside a sandboxed iframe with an opaque origin (origin = 'null'). Because of that, creating a Web Worker from a URL like https://app.powerbi.com/.../worker.js fails the browser’s origin checks, which is why you see:
Failed to construct 'Worker' ... cannot be accessed from origin 'null'
So to your question: loading a separate worker.js file by URL is effectively restricted in Power BI Service and isn’t something the visual can override.
Workable alternatives are:
Bundle the worker and create it via a Blob URL (or bundler-supported worker import), instead of loading worker.js as a hosted script.
If the worker is mainly for heavy compute, consider moving the processing outside the visual (backend/Fabric) or running the WASM on the main thread if feasible.
In short: Power BI is unlikely to allow externally loaded worker scripts, so the practical solution is to inline/bundle the worker rather than fetch it as a separate file.
- keerthanabasaRegular Visitor
Thanks for the solution, It resolved the worker.js error on using BLOB.
blob:null/ Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'WorkerGlobalScope': Failed to parse URL from mMapSDK.worker.wasm at instantiateAsync at createWasm.
mohit_sakhare , Any possible fixes to resolve this?
- v-tejramaCommunity Support
Hi keerthanabasa ,
Thank you mohit_sakhare for the response provided!
Has your issue been resolved? If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.
Thank you.- v-tejramaCommunity Support
Hi keerthanabasa ,
I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.
Thank you.