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

Module did not self-register #38

Open
CumpsD opened this issue Dec 20, 2021 · 1 comment
Open

Module did not self-register #38

CumpsD opened this issue Dec 20, 2021 · 1 comment

Comments

@CumpsD
Copy link

CumpsD commented Dec 20, 2021

I am trying out blake3 2.1.7 but am getting the following error:

node:events:346
      throw er; // Unhandled 'error' event
      ^
Error: Module did not self-register: '/home/ubuntu/ironfish-src2/node_modules/blake3/dist/native.node'.
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1151:18)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/ubuntu/ironfish-src2/node_modules/blake3/dist/node-native/native.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
Emitted 'error' event on process instance at:
    at emitUnhandledRejectionOrErr (node:internal/event_target:639:11)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:464:9)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28) {
  code: 'ERR_DLOPEN_FAILED'
}

I have tried using Node 16 with ubuntu-latest-93.node and Node 15 with ubuntu-latest-88.node but both give the same error.

Any ideas what causes this error?

@wmthor
Copy link

wmthor commented Dec 26, 2021

I'm facing this issue as well. I've figured out that it occurs when I have instances of require('blake3') in both the main thread and worker thread at the same time.

index.js

const {Worker} = require("worker_threads");

const blake3 = require('blake3');

const worker = new Worker("./worker.js");

worker.once("message", result => {
  console.log(result);
});

worker.on("error", error => {
  console.log(error);
});

worker.on("exit", exitCode => {
  console.log(exitCode);
})

worker.js

const blake3 = require('blake3');

const {parentPort, workerData} = require("worker_threads");

parentPort.postMessage(doNothing())

function doNothing() {
  return null;
}

Edit: It also occurs when running multiple instances of the workers at the same time. It seems to be a general issue of multiple threads using the native binding. The workaround looks to be to userequire('blake3-wasm') instead and skipping the native binding.

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

No branches or pull requests

2 participants