How to properly use worker in the browser mode?
See original GitHub issueHello,
I’m trying to use this module in the browser. I’m using the following code according to the doc:
const { Worker } = require("flexsearch");
var myWorker = new Worker();
When I try the search, myWorker.search(‘some test’); I get the following error:
“TypeError: Cannot read property ‘postMessage’ of undefined at eval (webpack://@somepath./node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/flexsearch.bundle.js?:23:229)”
I’m using Webpack to build my package, it seems like I missed something obvious but I cannot figure out what.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to Effectively Use Browser Caching and Service Workers
Learn more advanced front-end and full-stack development at: https://www.fullstackacademy.comService Workers are JavaScript web workers used ...
Read more >Using Service Workers - Web APIs | MDN
In Firefox, Service Worker APIs are hidden and cannot be used when the user is in private browsing mode, or when history is...
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 >Web Workers Demystified - Medium
A web worker is a simple way to run Javascript code in background threads on the browser. The code in the workers will...
Read more >Web workers in JavaScript and when to use them - bene : studio
If you put this code into the browser console in Developer Tools, you will see that the page becomes unresponsive which is due...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ts-thomas Could this line use the following check instead?
In an electron window with
nodeIntegration
enabled it will look like a node process, but actually needs to be a browser processThis fix is included in v0.7.23