question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running in WebWorker

See original GitHub issue

I see that the demo page runs in a worker thread but this code isn’t included in the Node distribution and from what I can see from the demo page, it is quite complicated. I can’t get the normal version loading because of

Uncaught (in promise) TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).
    at loadWasmModule (argon2.js:74)
    at argon2.js:63

Are you planning to include proper worker support & code in the distribution as well? Otherwise, is there any simple way to get it working?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tasncommented, Jan 7, 2021

I built a wrapper module so you can easily use this module as a webworker in a webpack (or other project). Argon2-browser is loaded inline (no import scripts which don’t get SRI!!), so you can easily use it in any project. yarn add argon2-webworker https://github.com/etesync/argon2-webworker

I haven’t implemented all of the API, but the API is identical to this module, so using it is exactly the same.

0reactions
D-Nicecommented, Aug 25, 2020

In my case, I had the luxury of having webpack available which makes it super simple to run this in a webworker, in what I consider to be a very maintanable way.

  1. Use webpack in your project (maybe other bundlers work but steps will differ).
  2. Install worker-loader npm i --save-dev worker-loader .
  3. Then make and use your worker under src just as you would any other js, no need to worry about importscripts… don’t even have to change your webpack config, can just do an inlined import of your worker.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Web Workers - Web APIs - MDN Web Docs
Web Workers are a simple means for web content to run scripts in background threads. The worker thread can perform tasks without interfering ......
Read more >
Running fetch in a web worker - Medium
A Web Worker is a simple means for web content to run scripts in background threads. Think of it as a background process...
Read more >
Managing Long-Running Tasks In A React App With Web ...
In this tutorial, we're going to learn how to use the Web Worker API to manage time-consuming and UI-blocking tasks in a JavaScript...
Read more >
Reliably detect if the script is executing in a web worker
Any standard mechanism for detecting if a JavaScript is executing as a WebWorker? ... Can a JavaScript function check if its being run...
Read more >
HTML Web Workers API - W3Schools
A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found