vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.33k stars 1.02k forks source link

fix: missing entrypoint when launched from self-created child process #1949

Closed Luzzifus closed 1 year ago

Luzzifus commented 1 year ago

There is a bug that occurs when a packaged executable (Windows 11) is launched from a child process which was created by the executable itself (like for a self updating executable). This bug was reported already in #1861.

It seems that there is a conditional block at the start of bootstrap.js which has the potential to cause ENTRYPOINT to become undefined. I have to admit that I don't understand the purpose of the that specific code block, but I understand as much as that there always needs to be an entrypoint to successfully launch the executable. So I simply added an else statement as a fall back to the DEFAULT_ENTRYPOINT.

Luzzifus commented 1 year ago

Could you add a test that covers this?

I added one. I also changed the actual fix a little bit to make sure it really only is a fallback for the case that argv[1] is undefined after all other modifications to argv.

Luzzifus commented 1 year ago

Thanks for the test. Could you also fix lint issues please?

How would I do that? I ran yarn lint and yarn fix locally and it didn't change anything and I also got neither warnings nor errors for the files I changed/added.

robertsLando commented 1 year ago

The error is shown here: https://github.com/vercel/pkg/actions/runs/5321783982/jobs/9638103625?pr=1949#step:6:19

Try using npx eslint lib prelude test --fix

Luzzifus commented 1 year ago

Got it. Fixed.