wilk / microjob

A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.
https://wilk.github.io/microjob/
MIT License
2.02k stars 47 forks source link

Error running example code #8

Closed ryharrin closed 6 years ago

ryharrin commented 6 years ago

When running the example code, I receive the following error: { Error: Cannot find module '/Users/rharrington/src/temp/microjobtest/src/worker.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at MessagePort.port.on (internal/worker.js:445:27) at MessagePort.emit (events.js:182:13) at MessagePort.onmessage (internal/worker.js:66:8) code: 'MODULE_NOT_FOUND' }

Details included below:

OS: OSX v10.13.4

Node: v10.10.0

command: node --experimental-worker index.js

index.js: (async () => { const { job } = require('microjob') try { // this function will be executed in another thread const res = await job(() => { let i = 0 for (i = 0; i < 1000000; i++) { Array.from({length: 1000}, () => Math.floor(Math.random() * 1000)).sort() } return i }) console.log(res) // 1000000 } catch (err) { console.error(err) } })()

package.json : { "name": "microjobtest", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "microjob": "^0.1.0" } }

wilk commented 6 years ago

Thanks, this bug was introduced during the definition of the worker pool. It's now fixed in version 0.1.1. I'm closing it.

ryharrin commented 6 years ago

Thanks!