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

v8-profiler-next fails when loaded from multiple threads? #36

Closed
philz opened this issue Apr 4, 2022 · 1 comment
Closed

v8-profiler-next fails when loaded from multiple threads? #36

philz opened this issue Apr 4, 2022 · 1 comment

Comments

@philz
Copy link

philz commented Apr 4, 2022

The following script fails with "Module did not self-register" errors using v8-profiler-next 1.5.1. This is similar to hyj1991/v8-profiler-next#9 and perhaps the fixes haven't been ported over?

I'm currently on Node v12.20.1.

$cat prof.js
const {Worker, isMainThread, parentPort} = require('worker_threads');
const fs = require('fs');

function work() {
    require('v8-profiler-next');
    parentPort.postMessage('hi');
}

if (isMainThread) {
    require('v8-profiler-next');
    new Worker(__filename).on('message', (result) => {
        console.log(result);
    });
} else {
    work();
}
$node --version
v12.20.1
$node prof.js

events.js:291
      throw er; // Unhandled 'error' event
      ^
Error: Module did not self-register: '.../src/hyperbase/node_modules/v8-profiler-next/build/Release/profiler.node'.
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (.../src/hyperbase/node_modules/v8-profiler-next/dispatch.js:2:17)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
Emitted 'error' event on Worker instance at:
    at Worker.[kOnErrorMessage] (internal/worker.js:242:10)
    at Worker.[kOnMessage] (internal/worker.js:252:37)
    at MessagePort.<anonymous> (internal/worker.js:168:57)
    at MessagePort.emit (events.js:314:20)
    at MessagePort.onmessage (internal/worker/io.js:80:8)
    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:11:10)
@philz
Copy link
Author

philz commented Apr 4, 2022

Filed at hyj1991/v8-profiler-next#37 instead. Sorry for the noise. Got -next and -node8 mixed up.

@philz philz closed this as completed Apr 4, 2022
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

1 participant