Skip to content

Commit 38a90df

Browse files
author
DimitarTachev
committed
fix: detach from the Native iOS debugger in order to avoid app freeze on unhandled exceptions
1 parent c376458 commit 38a90df

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

lib/common/helpers.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,11 @@ export function getHash(str: string, options?: { algorithm?: string, encoding?:
463463
}
464464

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

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

487-
const socket = await factory();
488-
socket.on("connect", () => {
489-
socket.removeListener("error", tryConnectAfterTimeout);
490-
isResolved = true;
491-
resolve(socket);
492-
});
493-
socket.on("error", tryConnectAfterTimeout);
487+
try {
488+
const socket = await factory();
489+
socket.on("connect", () => {
490+
socket.removeListener("error", tryConnectAfterTimeout);
491+
isResolved = true;
492+
clearTimeout(connectionTimer);
493+
resolve(socket);
494+
});
495+
socket.on("error", tryConnectAfterTimeout);
496+
} catch (e) {
497+
lastKnownError = e;
498+
}
494499
}
495500

496501
await tryConnect();

lib/services/ios-debug-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
142142
}
143143
this._lldbProcess.stderr.pipe(process.stderr);
144144
this._lldbProcess.stdin.write("process continue\n");
145+
this._lldbProcess.stdin.write("detach\n");
145146

146147
return this.wireDebuggerClient(debugData, debugOptions);
147148
}

npm-shrinkwrap.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"gaze": "1.1.0",
4343
"iconv-lite": "0.4.11",
4444
"inquirer": "0.9.0",
45-
"ios-device-lib": "0.4.14",
45+
"ios-device-lib": "0.4.15",
4646
"ios-mobileprovision-finder": "1.0.10",
4747
"ios-sim-portable": "4.0.2",
4848
"istextorbinary": "2.2.1",

0 commit comments

Comments
 (0)