Skip to content

Require for native add-ons in worker_threads #34

@tshemsedinov

Description

@tshemsedinov

Some modules, for example argon2 can't be loaded in worker threads.

Try load.js with the following code:

'use strict';

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

const argon2 = require('argon2');
console.dir({ argon2 });

new Worker('./thread.js');

and thread.js with the following code:

'use strict';

const argon2 = require('argon2');

console.dir({ argon2 });

we will get exception:

Error: Module did not self-register.
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:775:18)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at bindings (.../node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (.../node_modules/argon2/argon2.js:4:37)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)

We need to find solution to use worker thread in impress. @nechaido you can assign this task to developers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions