I am attempting to employ a WebWorker within a WebExtension on an Azure DevOps Server.
Data processing for a large repository can be quite resource-intensive, prompting me to utilize a WebWorker for background calculations.
However, when I try to instantiate the WebWorker with
new Worker("static/js/WorkerLoadTree.js")
:
//CREATE WORKER
console.log("BEFORE NEW WORKER CALL")
BackgroundWorker = new Worker("static/js/WorkerLoadTree.js");
console.log("AFTER NEW WORKER CALL")
In Microsoft Edge browser, I encounter:
https://i.sstatic.net/EOswn.png
On Google Chrome, the error message provides more insights:
VSS.SDK.min.js:2 Rejected XDM promise with no reject callbacks n._reject @ VSS.SDK.min.js:2
VSS.SDK.min.js:2 DOMException: Failed to construct 'Worker': Script at 'http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/static/js/WorkerLoadTree.js' cannot be accessed from origin 'null'.
at WorkerStart (http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/static/js/WorkerMain.js:13:32)
at FillCode (http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/index.html:284:3)
at http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/index.html:144:6
at n._wrapCallback (http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/lib/VSS.SDK.min.js:2:951)
at Array.<anonymous> (http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/lib/VSS.SDK.min.js:2:647)
at http://136.310.18.216:8070/_apis/public/gallery/publisher/user/extension/SearchRepos/1.0.13/assetbyname/lib/VSS.SDK.min.js:2:1383 n._reject @ VSS.SDK.min.js:2
Failed to load resource: net::ERR_UNEXPECTED :8070/DefaultCollection/_apis/Contribution/HierarchyQuery/project/09737d31-b39f-49a1-8973-4a702cc4be92:1
It appears that there is an issue with loading the WorkerLoadTree.js
file. Can you confirm if the method of calling the worker is correct? How can the worker access a JavaScript file within an extension?
The file structure of my extension is as follows:
───SearchRepos
│ icon.png
│ index.html
│ SearchRepos-1.0.14.vsix
│ package-lock.json
│ package.json
│ vss-extension.json
│
├───node_modules
│ └───vss-web-extension-sdk
│ ...
│
└───static
├───css
│ main.css
│
├───js
│ main.js
│ WorkerLoadCode.js <- WebWorker
│ WorkerLoadTree.js <- WebWorker
│ WorkerMain.js
│
├───lib
│ jquery-3.4.1.min.js
│ jstree.js
│
└───themes
...
Additional Information:
Azure DevOps Server 17.143.28912.1 (AzureDevOps2019.0.1)