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 (case with worker) #2480

Closed
tzvetelin-vassilev opened this issue Jan 6, 2025 · 1 comment
Closed

Module did not self-register (case with worker) #2480

tzvetelin-vassilev opened this issue Jan 6, 2025 · 1 comment

Comments

@tzvetelin-vassilev
Copy link

The problem comes when try to load the library in a worker thread. The following snippet is a reproducible example:

// sample.mjs

import {Worker, isMainThread} from "worker_threads"

let name = isMainThread ? "main" : "worker"

try {
  let canvas = await import("canvas");

  console.log(`[${name}] canvas`, !!canvas)
}
catch(e) {
  console.error(e);
}

if (isMainThread)
  new Worker("./sample.mjs");

node sample.mjs console result is:

[main] canvas true
Error: Module did not self-register: '.../node_modules/canvas/build/Release/canvas.node'.
    at Object..node (node:internal/modules/cjs/loader:1586:18)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/vassilev/Projects/ink-inspector/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Object..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function._load (node:internal/modules/cjs/loader:1104:12) {
  code: 'ERR_DLOPEN_FAILED'

node version: v20.18.0
canvas version: v3.0.0

@chearon
Copy link
Collaborator

chearon commented Jan 6, 2025

We don't support worker threads yet, but most of the work has been done, so stay tuned. Follow #1394 for updates.

@chearon chearon closed this as completed Jan 6, 2025
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