Skip to content

fix: detach from the Native iOS debugger in order to avoid app freeze on unhandled exceptions #3938

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

Merged
merged 1 commit into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,11 @@ export function getHash(str: string, options?: { algorithm?: string, encoding?:
}

export async function connectEventuallyUntilTimeout(factory: () => Promise<net.Socket>, timeout: number): Promise<net.Socket> {
return new Promise<net.Socket>(async(resolve, reject) => {
return new Promise<net.Socket>(async (resolve, reject) => {
let lastKnownError: Error;
let isResolved = false;

setTimeout(function () {
const connectionTimer = setTimeout(function () {
if (!isResolved) {
isResolved = true;
reject(lastKnownError);
Expand All @@ -484,13 +484,18 @@ export async function connectEventuallyUntilTimeout(factory: () => Promise<net.S
setTimeout(tryConnect, 1000);
};

const socket = await factory();
socket.on("connect", () => {
socket.removeListener("error", tryConnectAfterTimeout);
isResolved = true;
resolve(socket);
});
socket.on("error", tryConnectAfterTimeout);
try {
const socket = await factory();
socket.on("connect", () => {
socket.removeListener("error", tryConnectAfterTimeout);
isResolved = true;
clearTimeout(connectionTimer);
resolve(socket);
});
socket.on("error", tryConnectAfterTimeout);
} catch (e) {
lastKnownError = e;
}
}

await tryConnect();
Expand Down
1 change: 1 addition & 0 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
}
this._lldbProcess.stderr.pipe(process.stderr);
this._lldbProcess.stdin.write("process continue\n");
this._lldbProcess.stdin.write("detach\n");

return this.wireDebuggerClient(debugData, debugOptions);
}
Expand Down
6 changes: 3 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"gaze": "1.1.0",
"iconv-lite": "0.4.11",
"inquirer": "0.9.0",
"ios-device-lib": "0.4.14",
"ios-device-lib": "0.4.15",
"ios-mobileprovision-finder": "1.0.10",
"ios-sim-portable": "4.0.2",
"istextorbinary": "2.2.1",
Expand Down