Skip to content

Commit c451bc9

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 c451bc9

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
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
}

0 commit comments

Comments
 (0)