pkg icon indicating copy to clipboard operation
pkg copied to clipboard

multi-process(cluster) not working with v8 options?

Open jimying opened this issue 4 years ago • 2 comments

What version of pkg are you using?

5.5.1

What version of Node.js are you using?

v12.22.8

What operating system are you using?

centos7

What CPU architecture are you using?

x86_64 & arm64

What Node versions, OSs and CPU architectures are you building for?

node12-linux

Describe the Bug

Program run in Muti-process mode, pkg with --options (v8) , app run error Simple test code:

const cluster = require('cluster');
if (cluster.isMaster) {
    for (let i = 0; i < 2; i++)
        cluster.fork();
}
else if (cluster.isWorker){
    console.log("Create worker_%d(%d)", cluster.worker.id, process.pid);
}

package it with v8-options:

pkg -t linux index.js  --options max-old-space-size=3072

when app run, error:

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '/git/test/--max-old-space-size=3072'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1819:46)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Function.runMain (pkg/prelude/bootstrap.js:1847:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

PS

I also test with the node V16.13.1,    same error

Expected Behavior

run fine in multi-process mode

To Reproduce

As decribe

jimying avatar Dec 30 '21 01:12 jimying

I find some one had face same probem, #459

jimying avatar Dec 30 '21 02:12 jimying

Before fork child process, setup master, will fix error

cluster.setupMaster({
        execArgv: []
    }); 

jimying avatar Dec 30 '21 02:12 jimying

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Oct 12 '22 00:10 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar Oct 18 '22 00:10 github-actions[bot]

Please reopen this issue and merge the linked PR.

lamualfa avatar Oct 27 '22 09:10 lamualfa

Temporary solution:

https://github.com/vercel/pkg/issues/1047#issuecomment-1293431841

lamualfa avatar Oct 27 '22 14:10 lamualfa