Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching CJS plugin on desktop - worker support? #3785

Closed
cmdcolin opened this issue Jul 6, 2023 · 3 comments · Fixed by #3796
Closed

Fetching CJS plugin on desktop - worker support? #3785

cmdcolin opened this issue Jul 6, 2023 · 3 comments · Fixed by #3796
Labels
enhancement New feature or request

Comments

@cmdcolin
Copy link
Collaborator

cmdcolin commented Jul 6, 2023

I noticed that our rpcWorker does not provide a 'fetchCJS' callback, and the fetchCJS callback in place uses window.require so just adding it with a copy of the current one may not work. But, if fetchCJS is helpful/needed in jbrowse-desktop on a webworker, we may want to remedy this?

@cmdcolin cmdcolin added the enhancement New feature or request label Jul 6, 2023
@cmdcolin
Copy link
Collaborator Author

wanted to see what you thought of this one @garrettjstevens

@garrettjstevens
Copy link
Collaborator

The existing fetchCJS won't work in the webworker since there is no window, but with a small adjustment to replace window with globalThis, I think it will work.

One concern that I just learned about, though, is that native Node.js modules are not thread-safe, and electron strongly recommends not using them in web workers. We already use native node modules in the workers, though, e.g. when we use fs in LocalFile from generic-filehandle when doing openLocation on a worker thread. So this wouldn't be a new risk, but still could be something to consider.

@rbuels
Copy link
Contributor

rbuels commented Jul 11, 2023

We already use native node modules in the workers, though, e.g. when we use fs in LocalFile from generic-filehandle when doing openLocation on a worker thread. So this wouldn't be a new risk, but still could be something to consider.

Above that, however, it does at least say that "All built-in modules of Node.js are supported in Web Workers", so I think our use of fs is probably ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants