Propagate errors properly when cert exchange fails

Summary:
Certificate exchange errors should be communicated back to the user, as they are often actionable, and otherwise leave users in a stuck state.

Also removed the ServerController interface, upgraded the listener types to get at the necessary internal apis typewise that were already available.

Removed that error wrapping utility complaining about idb installation, this is rarely ever the problem anymore, and it hides the underlying error.

Reviewed By: nikoant

Differential Revision: D34105452

fbshipit-source-id: 3b3cd0b99cecbda26dfd0744a90690fe568a5ea5
This commit is contained in:
Michel Weststrate
2022-02-09 04:21:47 -08:00
committed by Facebook GitHub Bot
parent 5805d03091
commit 597f679ed3
5 changed files with 50 additions and 50 deletions

View File

@@ -210,17 +210,15 @@ async function push(
): Promise<void> {
await memoize(checkIdbIsInstalled)(idbPath);
return wrapWithErrorMessage(
reportPlatformFailures(
safeExec(
`${idbPath} file push --log ${idbLogLevel} --udid ${udid} --bundle-id ${bundleId} '${src}' '${dst}'`,
)
.then(() => {
return;
})
.catch((e) => handleMissingIdb(e, idbPath)),
`${operationPrefix}:push`,
),
return reportPlatformFailures(
safeExec(
`${idbPath} file push --log ${idbLogLevel} --udid ${udid} --bundle-id ${bundleId} '${src}' '${dst}'`,
)
.then(() => {
return;
})
.catch((e) => handleMissingIdb(e, idbPath)),
`${operationPrefix}:push`,
);
}
@@ -233,18 +231,16 @@ async function pull(
): Promise<void> {
await memoize(checkIdbIsInstalled)(idbPath);
return wrapWithErrorMessage(
reportPlatformFailures(
safeExec(
`${idbPath} file pull --log ${idbLogLevel} --udid ${udid} --bundle-id ${bundleId} '${src}' '${dst}'`,
)
.then(() => {
return;
})
.catch((e) => handleMissingIdb(e, idbPath))
.catch((e) => handleMissingPermissions(e)),
`${operationPrefix}:pull`,
),
return reportPlatformFailures(
safeExec(
`${idbPath} file pull --log ${idbLogLevel} --udid ${udid} --bundle-id ${bundleId} '${src}' '${dst}'`,
)
.then(() => {
return;
})
.catch((e) => handleMissingIdb(e, idbPath))
.catch((e) => handleMissingPermissions(e)),
`${operationPrefix}:pull`,
);
}
@@ -282,23 +278,12 @@ function handleMissingPermissions(e: Error): void {
console.warn(e);
throw new Error(
'Cannot connect to iOS application. idb_certificate_pull_failed' +
'Idb lacks permissions to exchange certificates. Did you install a source build ([FB] or enable certificate exchange)? ' +
e,
'Idb lacks permissions to exchange certificates. Did you install a source build ([FB] or enable certificate exchange)? See console logs for more details.',
);
}
throw e;
}
function wrapWithErrorMessage<T>(p: Promise<T>): Promise<T> {
return p.catch((e: Error) => {
console.warn(e);
// Give the user instructions. Don't embed the error because it's unique per invocation so won't be deduped.
throw new Error(
"A problem with idb has ocurred. Please run `sudo rm -rf /tmp/idb*` and `sudo yum install -y fb-idb` to update it, if that doesn't fix it, post in Flipper Support.",
);
});
}
async function isXcodeDetected(): Promise<boolean> {
return exec('xcode-select -p')
.then(({stdout}) => {