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

Fix importing the worker thread file #10

Merged
merged 2 commits into from
Jul 11, 2019

Conversation

derhuerst
Copy link
Contributor

@derhuerst derhuerst commented Jul 9, 2019

Before it would fail if you use crypto-hash with Node 12 (or anything with worker_threads rather). The tests didn't fail because they run with $PWD pointing to the repo.

const {sha512} = require('crypto-hash')
sha512('foo').then(console.log, console.error)
[Error: Cannot find module '/Users/j/playground/thread.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at MessagePort.<anonymous> (internal/main/worker_thread.js:139:25)
    at MessagePort.emit (events.js:200:13)
    at MessagePort.onmessage (internal/worker/io.js:70:8) {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}] {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

One way to test this might be to move test.js to test/index.js and then run cd test; ava index.js.

@sindresorhus sindresorhus changed the title make path to thread.js relative to file 🐛 Fix importing the worker thread file Jul 11, 2019
@sindresorhus sindresorhus merged commit 46f2f28 into sindresorhus:master Jul 11, 2019
@sindresorhus
Copy link
Owner

Thanks for catching this :)

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

Successfully merging this pull request may close these issues.

2 participants