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();
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();
}
await ProjectSettings.setPackagerInfoAsync(projectRoot, {
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();
}
await ProjectSettings.setPackagerInfoAsync(projectRoot, {
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();
}
await ProjectSettings.setPackagerInfoAsync(projectRoot, {
await stopTunnelsAsync(projectRoot);
if (await Android.startAdbReverseAsync(projectRoot)) {
ProjectUtils.logInfo(
projectRoot,
'expo',
'Successfully ran `adb reverse`. Localhost urls should work on the connected Android device.',
'project-adb-reverse'
);
} else {
ProjectUtils.clearNotification(projectRoot, 'project-adb-reverse');
}
const { username } = user;
let packageShortName = path.parse(projectRoot).base;
let expRc = await ProjectUtils.readExpRcAsync(projectRoot);
ngrok.addListener('statuschange', status => {
if (status === 'reconnecting') {
ProjectUtils.logError(
projectRoot,
'expo',
'We noticed your tunnel is having issues. This may be due to intermittent problems with our tunnel provider. If you have trouble connecting to your app, try to Restart the project, or switch Host to LAN.'
);
} else if (status === 'online') {
ProjectUtils.logInfo(projectRoot, 'expo', 'Tunnel connected.');
}
});
try {
let startedTunnelsSuccessfully = false;
// Some issues with ngrok cause it to hang indefinitely. After
// TUNNEL_TIMEOUTms we just throw an error.
import * as Watchman from './Watchman';
import * as Webpack from './Webpack';
import XDLError from './XDLError';
import * as Doctor from './project/Doctor';
import * as IosPlist from './detach/IosPlist';
// @ts-ignore IosWorkspace not yet converted to TypeScript
import * as IosWorkspace from './detach/IosWorkspace';
import { ConnectionStatus } from './xdl';
const EXPO_CDN = 'https://d1wp6m56sqw74a.cloudfront.net';
const MINIMUM_BUNDLE_SIZE = 500;
const TUNNEL_TIMEOUT = 10 * 1000;
const treekillAsync = promisify(treekill);
const ngrokConnectAsync = promisify(ngrok.connect);
const ngrokKillAsync = promisify(ngrok.kill);
type CachedSignedManifest =
| {
manifestString: null;
signedManifest: null;
}
| {
manifestString: string;
signedManifest: string;
};
let _cachedSignedManifest: CachedSignedManifest = {
manifestString: null,
signedManifest: null,
};
import * as Webpack from './Webpack';
import XDLError from './XDLError';
import * as Doctor from './project/Doctor';
import * as IosPlist from './detach/IosPlist';
// @ts-ignore IosWorkspace not yet converted to TypeScript
import * as IosWorkspace from './detach/IosWorkspace';
import { ConnectionStatus } from './xdl';
const EXPO_CDN = 'https://d1wp6m56sqw74a.cloudfront.net';
const MINIMUM_BUNDLE_SIZE = 500;
const TUNNEL_TIMEOUT = 10 * 1000;
const treekillAsync = promisify(treekill);
const ngrokConnectAsync = promisify(ngrok.connect);
const ngrokKillAsync = promisify(ngrok.kill);
type CachedSignedManifest =
| {
manifestString: null;
signedManifest: null;
}
| {
manifestString: string;
signedManifest: string;
};
let _cachedSignedManifest: CachedSignedManifest = {
manifestString: null,
signedManifest: null,
};
? 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') {