threads.js: Uncaught TypeError: importScripts.map is not a function(…)
I’m trying to use threads.js
do some some processing but am encountering this error:
Uncaught TypeError: importScripts.map is not a function(…)
The workflow goes like this. I first import Pool
from the threads
module:
import {Pool} from 'threads';
And then call it as in the documentation:
let jobA = this.threadPool.run(function(input, done) {
workerGetTilesetInfo(input);
done(input);
}, {
workerGetTilesetInfo: 'worker'
})
.on('done', function(job, message) {
console.log('done', message);
})
.on('error', function(job, error) {
console.log('error', error);
})
.send(outUrl);
The function getTilesetInfo
is defined in another javascript file called worker.js
. Is this a valid issue, or am I simply doing something wrong?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (12 by maintainers)
v1.0 beta is here with a whole new API. It will make your life much easier, esp. when
import
-ing modules 😉Closing.
A workaround is to create an absolute path for the worker from the current script’s path: