Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function stopTunnelsAsync(projectRoot: string) {
_assertValidProjectRoot(projectRoot);
// This will kill all ngrok tunnels in the process.
// We'll need to change this if we ever support more than one project
// open at a time in XDE.
let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);
let ngrokProcess = ngrok.process();
let ngrokProcessPid = ngrokProcess ? ngrokProcess.pid : null;
ngrok.removeAllListeners('statuschange');
if (packagerInfo.ngrokPid && packagerInfo.ngrokPid !== ngrokProcessPid) {
// Ngrok is running in some other process. Kill at the os level.
try {
process.kill(packagerInfo.ngrokPid);
} catch (e) {
ProjectUtils.logDebug(
projectRoot,
'expo',
`Couldn't kill ngrok with PID ${packagerInfo.ngrokPid}`
);
}
} else {
// Ngrok is running from the current process. Kill using ngrok api.
await ngrokKillAsync();
export async function stopTunnelsAsync(projectRoot: string): Promise {
_assertValidProjectRoot(projectRoot);
// This will kill all ngrok tunnels in the process.
// We'll need to change this if we ever support more than one project
// open at a time in XDE.
let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);
let ngrokProcess = ngrok.process();
let ngrokProcessPid = ngrokProcess ? ngrokProcess.pid : null;
ngrok.removeAllListeners('statuschange');
if (packagerInfo.ngrokPid && packagerInfo.ngrokPid !== ngrokProcessPid) {
// Ngrok is running in some other process. Kill at the os level.
try {
process.kill(packagerInfo.ngrokPid);
} catch (e) {
ProjectUtils.logDebug(
projectRoot,
'expo',
`Couldn't kill ngrok with PID ${packagerInfo.ngrokPid}`
);
}
} else {
// Ngrok is running from the current process. Kill using ngrok api.
await ngrokKillAsync();
export async function stopTunnelsAsync(projectRoot: string) {
await UserManager.ensureLoggedInAsync();
_assertValidProjectRoot(projectRoot); // This will kill all ngrok tunnels in the process. // We'll need to change this if we ever support more than one project // open at a time in XDE.
let packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);
let ngrokProcess = ngrok.process();
let ngrokProcessPid = ngrokProcess ? ngrokProcess.pid : null;
ngrok.removeAllListeners('statuschange');
if (packagerInfo.ngrokPid && packagerInfo.ngrokPid !== ngrokProcessPid) {
// Ngrok is running in some other process. Kill at the os level.
try {
process.kill(packagerInfo.ngrokPid);
} catch (e) {
ProjectUtils.logDebug(
projectRoot,
'expo',
`Couldn't kill ngrok with PID ${packagerInfo.ngrokPid}`
);
}
} else {
// Ngrok is running from the current process. Kill using ngrok api.
await ngrokKillAsync();
? expRc.manifestTunnelRandomness
: await Exp.getProjectRandomnessAsync(projectRoot);
return [
'packager',
randomness,
UrlUtils.domainify(username),
UrlUtils.domainify(packageShortName),
Config.ngrok.domain,
].join('.');
},
packagerInfo.ngrokPid
);
await ProjectSettings.setPackagerInfoAsync(projectRoot, {
expoServerNgrokUrl,
packagerNgrokUrl,
ngrokPid: ngrok.process().pid,
});
startedTunnelsSuccessfully = true;
ProjectUtils.logWithLevel(
projectRoot,
'info',
{
tag: 'expo',
_expoEventType: 'TUNNEL_READY',
},
'Tunnel ready.'
);
ngrok.addListener('statuschange', status => {
if (status === 'reconnecting') {
? expRc.manifestTunnelRandomness
: await Exp.getProjectRandomnessAsync(projectRoot);
return [
'packager',
randomness,
UrlUtils.domainify(username),
UrlUtils.domainify(packageShortName),
Config.ngrok.domain,
].join('.');
},
packagerInfo.ngrokPid
);
await ProjectSettings.setPackagerInfoAsync(projectRoot, {
expoServerNgrokUrl,
packagerNgrokUrl,
ngrokPid: ngrok.process().pid,
});
startedTunnelsSuccessfully = true;
ProjectUtils.logWithLevel(
projectRoot,
'info',
{
tag: 'expo',
_expoEventType: 'TUNNEL_READY',
},
'Tunnel ready.'
);
ngrok.addListener('statuschange', (status: string) => {
if (status === 'reconnecting') {