adding reason on detach

This commit is contained in:
Tommy D. Rossi
2025-11-16 09:27:16 +01:00
parent b67f736bba
commit ac3a97dbda
+5 -4
View File
@@ -43,12 +43,12 @@ export class RelayConnection {
private _ws: WebSocket;
private _closed = false;
private _onCloseCallback?: () => void;
private _onTabDetachedCallback?: (tabId: number) => void;
private _onTabDetachedCallback?: (tabId: number, reason: chrome.debugger.DetachReason) => void
constructor({ ws, onClose, onTabDetached }: {
ws: WebSocket;
onClose?: () => void;
onTabDetached?: (tabId: number) => void;
onTabDetached?: (tabId: number, reason: `${chrome.debugger.DetachReason}`) => void;
}) {
this._ws = ws;
this._onCloseCallback = onClose;
@@ -197,6 +197,7 @@ export class RelayConnection {
debugLog('Connection closing, attached tabs count:', this._attachedTabs.size);
this._closed = true;
chrome.debugger.onEvent.removeListener(this._onDebuggerEvent);
chrome.debugger.onDetach.removeListener(this._onDebuggerDetach);
@@ -253,7 +254,7 @@ export class RelayConnection {
});
};
private _onDebuggerDetach = (source: chrome.debugger.Debuggee, reason: string): void => {
private _onDebuggerDetach = (source: chrome.debugger.Debuggee, reason: `${chrome.debugger.DetachReason}`): void => {
const tabId = source.tabId;
debugLog('_onDebuggerDetach called for tab:', tabId, 'reason:', reason, 'isAttached:', tabId ? this._attachedTabs.has(tabId) : false);
@@ -264,7 +265,7 @@ export class RelayConnection {
debugLog(`Manual debugger detachment detected for tab ${tabId}: ${reason}`);
debugLog('User closed debugger via Chrome automation bar, calling onTabDetached callback');
this._onTabDetachedCallback?.(tabId);
this._onTabDetachedCallback?.(tabId, reason);
this.detachTab(tabId);
};