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

Getting "Module did not self-register. " when using worker_threads in older heroku apps #727

Closed
jan-osch opened this issue Oct 28, 2019 · 3 comments

Comments

@jan-osch
Copy link

I I am repeatedly running into this issue. I am getting an error like this, and my worker fails to start:

Module did not self-register. 
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1003:18) 
    at Module.load (internal/modules/cjs/loader.js:812:32) 
    at Function.Module._load (internal/modules/cjs/loader.js:724:14) 
    at Module.require (internal/modules/cjs/loader.js:849:19) 
    at require (internal/modules/cjs/helpers.js:74:18) 
    at Object.<anonymous> (/app/.heroku/heroku-nodejs-plugin/index.js:1190:19) 
    at __webpack_require__ (/app/.heroku/heroku-nodejs-plugin/index.js:20:30) 
    at Object.<anonymous> (/app/.heroku/heroku-nodejs-plugin/index.js:132:21) 
    at __webpack_require__ (/app/.heroku/heroku-nodejs-plugin/index.js:20:30) 
    at Object.<anonymous> (/app/.heroku/heroku-nodejs-plugin/index.js:102:17)  

I am using a Heroku pipeline for my app, and this issue error occurs only on apps that exist for some time (mainly on staging and on production ); it never happens in the review apps, where the same worker starts without any problem. I guess it might have something to do with staging and production migrating from node v10 to v12 some months ago.

Npm: 6.12.0
Node: v12.13.0
Stack: heroku-18

I have removed almost everything from my worker, and it still happens.

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

parentPort.on('message', async (data) => {
  const { port } = data;
  try {
    const bytecode = Buffer.from('');
    port.postMessage({ bytecode });
  } catch (error) {
    port.postMessage({ error: error.message ? error.message : error.toString() });
  }
  port.close();
});
@jan-osch
Copy link
Author

jan-osch commented Nov 7, 2019

For anyone that encounters this problem - make sure to disable both "Enhanced Language Metrics" and "Node Language Metrics" in metrics settings in Heroku. The current implementation of the metrics system in Heroku is incompatible with some worker_threads scenarios.

Screenshot 2019-11-07 at 09 24 40

@danielleadams
Copy link
Contributor

Spoke with @jan-osch and we discovered that this was the issue. We will hopefully come up with a solution, but this unfortunately won't be a quick fix.

To ensure the feature is turned off, run heroku labs -a APP_NAME and confirm that under App Features that the nodejs-language-metrics feature is disabled.

@danielleadams
Copy link
Contributor

@jan-osch I opened a new issue (heroku/heroku-nodejs-plugin#13) to keep track of the issue, so I'm going to close this one. Thanks for bringing this to our attention!

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