blake3 icon indicating copy to clipboard operation
blake3 copied to clipboard

Module did not self-register

Open CumpsD opened this issue 2 years ago • 1 comments

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?

CumpsD avatar Dec 20 '21 22:12 CumpsD

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.

wmthor avatar Dec 26 '21 04:12 wmthor