-
Notifications
You must be signed in to change notification settings - Fork 262
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
Allow electron process forks of modules that use pre-gyp #279
Conversation
Thanks for this PR @bcomnes and especially for the detailed description of the problem over at #278. I'm the maintainer of node-pre-gyp and happy to accept this PR once there are tests. I'm not an electron user so I'd love help on how to best set up tests to confirm this is working and ensure it never regresses (which will run on travisci). Are writing unit tests something you could do? Or could you advise on how to test manually and maybe others could help convert those into unit tests? |
👌 I'll put something together today. |
A decent test would be to basically try to load a node-pre-gyp module in a module running in a childProcess.fork of electron and see if it throws or not. Would you be opposed to pulling in https://github.com/electron-userland/electron-prebuilt and https://github.com/electron/electron-rebuild as a dev dependency? Basically we would need to unit-testify https://github.com/ballpit/electron-sqlite3-fork-bug/blob/master/main.js#L14-L18 |
The other weird thing about this is requiring electron. Ideally we could pull off the correct electron version from the thing that actually called the fork, rather than an action-at-a-distancey require resolve of a package.json. I'll ask upstream how we can do this. |
Oh crap, I just pushed some unintentional files up. Fixing. |
Ok I made a few changes:
Is that enough testing for this you think? Or do we want to add more of an acceptance / integration test closer to what https://github.com/ballpit/electron-sqlite3-fork-bug/blob/master/main.js tests for? |
@springmeyer any feedback on the tests/current state of the PR? EDIT: Crap, broken tests. Fixing now. |
Rebased. |
@springmeyer Do you have any feedback on the tests I added? |
@bcomnes - made a request for a few minor changes. If you can address those then I am willing to merge. I admit that I don't fully understand the changes or how they work. So I would love if anyone else that uses electron could weight in. |
Ok, cleaned up those two issue, and rebased. To TLDR explain the issue: when forking a process in electron, a special ENV var is introduced to the forked process environment ( The only real weirdness here is the electron version resolution. Ideally this would also come in from the ENV of the forked process, but its not available yet. I'm currently working with the electron team to get that in (see electron/electron#9058) and will PR that improved method once its available. |
Hrmmm tests are failing now. Any idea if its because of what I'm doing? |
@bcomnes - I think they may be unrelated. Can you rebase against the master branch and see if things are fixed? |
Rebased. Fingers crossed! |
In a spat of inspiration to make the world slightly better this morning, I squashed and rebased this. An alternative PR for the same problem is here: #343 It looks like the difference between the two is ^^ that one requires you to pass in an ENV var yourself, this PR attempts to resolve the correct electron version for you. Personally, I think this is how it should work, but the code is a little more ugly until we can support from upstream electron. Getting rock solid sqlite support in electron would be amazing, and this would help make that happen. |
All tests passing locally. CI seems to be failing on unrelated tests 🤔 any ideas? |
@springmeyer any clue whats going on in the failed runs? Also what happened to travis? |
Hey guys, thanks for your work! Please make this merge finally happen! |
Thanks so much @bcomnes. Would love to land this. At the same time I don't have time or ability to review or merge currently. Nor debug travis, but it might be something like mapbox/gzip-hpp#33 which resulted from .org -> .com issues I think. |
@bcomnes it looks like electron made the change you wanted: |
@JakeRadMSFT The thing that I wanted to remove was https://github.com/mapbox/node-pre-gyp/pull/279/files#diff-314ae8d53157a25e4458ced25e711105R87 electron/electron#16450 adds a |
Ok, re-reading this. Totally untested, but: IF Closing. |
Confirmed that updating to Electron v6 (currently in beta) fixed the issue for me. E.g. I am able to use node-sqlite3 from an Electron-forked process. |
closes #278
I still need to check to see if this works in built electron apps, but this is fairly close to solving the issue of allowing
childProcess.fork
s in electron of node-pre-gyp modules.