Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Use WebWorker in WebExtension - Rejected XDM promise with no reject callbacks #145

Open
Nusserdt opened this issue Sep 4, 2019 · 0 comments

Comments

@Nusserdt
Copy link

Nusserdt commented Sep 4, 2019

I want to use a WebWorker inside a WebExtension on a Azure DevOps Server.

Processing data of a large repository cost a lot, so I want to use a WebWorker to calculate in Background.

But when I call 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")

I see in Edge:

image

and I see in Chrome a bit more details:

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 seems to be something wrong to load the WorkerLoadTree.js. Is the way to call correct? How can the worker access a js-file inside an extension?

My Web Extension File-Structure looks like:

───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
                  ...

Meta:

Azure DevOps Server 17.143.28912.1 (AzureDevOps2019.0.1)


Edit:

I could read out this log from a DOMException object

[object DOMException]: {code: 18, message: "SecurityError", name: "SecurityError"}
code: 18
message: "SecurityError"
name: "SecurityError"

__proto__: DOMExceptionPrototype
ABORT_ERR: 20
code: <Permission denied>

constructor: function DOMException() { [native code] }
DATA_CLONE_ERR: 25
DOMSTRING_SIZE_ERR: 2
HIERARCHY_REQUEST_ERR: 3
INDEX_SIZE_ERR: 1
INUSE_ATTRIBUTE_ERR: 10
INVALID_ACCESS_ERR: 15
INVALID_CHARACTER_ERR: 5
INVALID_MODIFICATION_ERR: 13
INVALID_NODE_TYPE_ERR: 24
INVALID_STATE_ERR: 11
message: <Permission denied>
name: <Permission denied>
NAMESPACE_ERR: 14
NETWORK_ERR: 19
NO_DATA_ALLOWED_ERR: 6
NO_MODIFICATION_ALLOWED_ERR: 7
NOT_FOUND_ERR: 8
NOT_SUPPORTED_ERR: 9
PARSE_ERR: 81
QUOTA_EXCEEDED_ERR: 22
SECURITY_ERR: 18
SERIALIZE_ERR: 82
SYNTAX_ERR: 12
TIMEOUT_ERR: 23

toString: function toString() { [native code] }
arguments: <Permission denied>
caller: <Permission denied>
name: "toString"

prototype: Object

__proto__: function() { [native code] }
TYPE_MISMATCH_ERR: 17
URL_MISMATCH_ERR: 21
VALIDATION_ERR: 16
WRONG_DOCUMENT_ERR: 4

__proto__: Object

Find this Workaround to load the WebWorker as Blob:

new Worker(URL.createObjectURL(new Blob(["("+worker_function.toString()+")()"], {type: 'text/javascript'})));

Locally everything works fine, but as Webextension I get:

Rejected XDM promise with no reject callbacks

[object DOMException]: {code: 18, message: "SecurityError", name: "SecurityError"}
code: 18
message: "SecurityError"
name: "SecurityError"

in VSS.SDK.min.js (2,1423)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant