-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
npm scripts instead of Makefile #502
Comments
The makefile buys automatic installation of dependencies if the package has been touched since the last make. With the inclusion of #561, the makefile will also allow headless systems to run the unit test suite (specifically, CircleCI) without internal problems to Electron/Chromium. Mimicking these two behaviors with simple NPM scripts would be difficult to do in a cross-platform friendly way (although not impossible). I'm in favor of modifying the build process to make it friendlier, and would like to get some feedback on what we should do. Off the cuff, I'd suggest something like Gulp, but that may be a bit heavy-handed for what we ultimately want to accomplish. Has anyone had trouble building this on Windows or any other OS where the makefile won't work? If so, have you been able to work around it? What does your make process look like? Do you have suggestions for build tools? |
This is a little tangential, but #571 made me wonder if the scripts added in #565 should really be part of Nightmare itself instead of the tests. That is, using Nightmare as a testing tool on a CI server somewhere seems like a major use-case. As it stands now, every user of Nightmare will have to know that they need to replicate Nightmare’s testing setup. If Nightmare just did all of that on its own before launching Electron, that would not only solve the deadlock for Nightmare’s own tests but also for other tests that leverage Nightmare. Doing so would also simplify the test script to the point where we might not need to worry about adding Gulp or some other solution to get things working on Windows. (Note I have no idea whether this is the problem being encountered in #571; that issue just made me think of this.) |
I'm going to purposefully totally ignore the NPM automagic make gives and focus on the framebuffer issues for the moment. I'm tentative on if we should automagically include the "run with Implementing your proposed changes has other setup complications, I'd think: I would want to preemptively check for an available framebuffer, but I don't know off the top of my head how to do that, especially in a cross-platform-friendly way. I'd love to hear your thoughts on that. Maybe I'm making it way more complicated than it needs to be.
Gulp is nice insofar as it skirts cross-platform issues. The runner task could also be exposed/registered. Introducing the complexity of managing the framebuffer ourselves is unpleasant at first blush, but does also mean avoiding another (large) dependency, and possibly fixing #224 . Which devil is worse? :P |
It might be enough to just be dumber. Maybe an env var like |
@Mr0grog Yeah, this may be a case of me trying to do an awful lot of work to save someone (me, if I can be totally selfish) ten seconds of setup grief. As time permits, I'll throw together a proposal on running Xvfb internally to Nightmare. Sound good? |
Works for me. Rewriting those scripts in JS makes sense, regardless, since it would still have to be done to get rid of the makefile. |
I have this (at least partially) working: instead of spinning up an Electron process directly, if the The main problem was that sending |
Is that https://github.com/rosshinkley/nightmare/tree/502 ?
|
@Mr0grog Yes, at least for the moment. I should probably go ahead and create a PR for it, but I know there are still some problematic tests. Anyway!
Well, it is. Kind of. Right now, each new Nightmare instance creates an Xvfb instance as well as an Electron instance (so Xvfb, Electron and Nightmare instances area all 1:1:1). They are created together, and in my opinion, should end together.
I don't know that handling a single Xvfb instance is going to work very well, at least not without the single-instance stuff getting done. I also don't think starting an instance and leaving it running is particularly clean. I'd prefer Nightmare to clean up after itself when it's finished. I'm going to lump these together:
Yes - from within Nightmare - but not without a bit of patching to how I don't know you can get the PID from the process tree, either. Maybe? I had problems with killing the process tree (that was my first attempt), but this might be worth a second look. The current incarnation adds another action to have Electron exit internally rather than killing the process from the parent. This works, but again, breaks the kill test. |
I guess I mainly meant: as a separate process. Start the xvfb server, then start Electron so you have two process handles instead of doing it together with
I wasn’t suggesting that it shouldn’t! Obviously this whole method requires more bookkeeping: whenever an Electron process ends, you’d have to check and see whether any others are running in order to know whether to stop xvfb. For that purpose, though, it could be as simple as a counter. |
Side note: I suspect the |
If I’m reading right, think that’s just because you’re changing the API. You’d have to update |
This is ripe for science. I, too am not certain how
It's not just
I figured as much. It's being wrapped twice. The exit code is an almost guaranteed lie. :P
Yes, and I did that locally, but at that moment, I thought it was not in the same spirit without modifying how Nightmare handles interrupts to call the newly-minted Electron self-desctruction mechanism. With a little distance, having the Electron PID bubbled up and having the signal handler call That said, it won't catch the other processes being orphaned (if they even can be), which gets at your point of running them independently. With all of that in mind, I think my next steps are to:
|
Update (aka "So what'd we learn?"):
You can run the processes independently, but it would appear that Electron picks whatever display is first available when not running as a child process. Unfortunately, this leads back to the same locking issue. I can kill off all of the X servers for a build up front, but that feels incorrect. Also, once in a while - with X started internally to Nightmare - Electron won't "pick up" the framebuffer. I need to spend some time to see if it can be remedied with using Again, I need to spend more time with this - it's possible I'm not using Xvfb properly. Open to suggestions. Also worth noting: this necessitated moving the Electron process start to the Nightmare queue instead of doing it directly in the constructor. The constructor starting Electron has been a long-standing bugbear for me, and I may split that part out into it's own PR. Thoughts?
Works great, provided the right X instance is picked up. The Electron instances share the running X instance just fine.
Also works with the same provisions as above.
This would not break anything as it requires an environment variable to be set to be used. Currrently, I have it set up to pick up if Nightmare is running under Circle, but I think I may remove that. I don't want to add new behavior to existing builds that may already account for Nightmare/Electron's special needs. Another thought crossed my mind as I was playing with moving the Electron start to the Nightmare queue: what about a retry? In the case of a lock, I believe the I thought I'd at least float the idea for feedback. |
Did you try setting the display via Alternatively, do the various XVFB displays show up in
Sounds good to me.
Sounds not-so-lovely, but it probably would be a reliable end-run around the problem. Sometimes the ugly fix is the one that works best, though. If it seems like the automatically running XVFB stuff is working, I might want to avoid it, personally. But if this is all proving too crazy and problematic, than letting it lie and taking the timeout/retry approach might be the right thing to do. |
I (embarrassingly) had forgotten about the Chromium command line switches. No, I have not, and will carve out some time to give that a whirl.
I wasn't trusting anything to come out of Electron. I didn't know how reliable the information that fell out would be. I can give this another peek and report back.
I'll do one more round of experiments to see if I can nudge this into a working state. The Chromium arguments seem promising, though. Thanks for that! |
It doesn't look like there has been any progress on this issue lately. I am going to go ahead and close it, but feel free to open it back up if anyone wants to take a stab at a PR. |
https://github.com/segmentio/nightmare/blob/master/Makefile
so that we can just run the test on windows seamlessly
makefile seems to be unfriendly to windows
The text was updated successfully, but these errors were encountered: