Skip to content

requiring C++ addon modules occurs 'Error: Module did not self-register.' with Worker Threads #21481

Closed
@ledsun

Description

  • Version: v10.5.0
  • Platform: Darwin nakajimashigeru-no-MacBook-Pro.local 16.7.0 Darwin Kernel Version 16.7.0: Fri Apr 27 17:59:46 PDT 2018; root:xnu-3789.73.13~1/RELEASE_X86_64 x86_64
  • Subsystem: worker

When C++ addon was loaded twice with worker threads, error below occurs:

events.js:167
      throw er; // Unhandled 'error' event
      ^
Error: Module did not self-register.
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:731:18)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at bindings (/Users/shigerunakajima/worker_thread_test/node_modules/bindings/bindings.js:81:44)
    at Object.<anonymous> (/Users/shigerunakajima/worker_thread_test/node_modules/libxmljs/lib/bindings.js:1:99)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
Emitted 'error' event at:
    at Worker.[kOnErrorMessage] (internal/worker.js:281:10)
    at Worker.[kOnMessage] (internal/worker.js:291:37)
    at MessagePort.Worker.(anonymous function).on (internal/worker.js:228:57)
    at MessagePort.emit (events.js:182:13)
    at MessagePort.onmessage (internal/worker.js:57:8)

To reproduce, run code below with --experimental-worker flag:

const libxmljs = require('libxmljs')
const {
  Worker
} = require('worker_threads')

new Worker(__filename)

When I try to require the sharp, same error occurs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    addonsIssues and PRs related to native addons.workerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions