Always launch a new process for the UA service. #516
Conversation
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | ||
|
||
function startService() { | ||
// Runs Electron as a node process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an advantage to launching Electron in this way? Should we perhaps launch argv[0]
or something to respawn? I'd quite like to not bring Electron into the UA service at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the one thing we know a tofino user has installed is the current electron build. They may not have node or anything else unless we add that as a dependency and ship it.
This looks mostly okay to me. I've left a few nits and comments throughout; interested to see the final form. |
I've updated this and it is ready for review though there are no tests right now. If you have suggestions beyond the webdriver tests verifying this as a side effect then let me know. At some point it might make sense to merge shared/user-agent-client.js and ui/browser/lib/user-agent.js, but by the time I discovered that I was almost done so I'd rather get this landed first and see if any issues come up. |
} | ||
|
||
async function backoffConnect() { | ||
let timedout = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: timedOut
.
Nifty! This works well locally, as long as I don't kill the initiating process. (That's an intentional limitation.) Throughout, I prefer full sentence comments, but whatever. |
Really? I can kill the initiating process on windows and it seemed to work last I checked. |
import path from 'path'; | ||
import EventEmitter from 'events'; | ||
import WebSocket from 'ws'; | ||
import request from 'request'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have isomorphic-fetch, do we also need request? We should have one or the other
Signed-off-by: Dave Townsend <dtownsend@oxymoronical.com>
This doesn't work yet (the UA service doesn't start up) but it should be pretty close. Basically we try to connect the websocket, if it fails we start a new service and connect again. The service closes itself once all clients have gone away.
Does this seem like it is along the right lines @ncalexan?
One issue is that there is a delay between starting the service and being able to connect. I almost want to make the main process listen for a connection from the service in that case.