adding reason on detach
This commit is contained in:
@@ -43,12 +43,12 @@ export class RelayConnection {
|
|||||||
private _ws: WebSocket;
|
private _ws: WebSocket;
|
||||||
private _closed = false;
|
private _closed = false;
|
||||||
private _onCloseCallback?: () => void;
|
private _onCloseCallback?: () => void;
|
||||||
private _onTabDetachedCallback?: (tabId: number) => void;
|
private _onTabDetachedCallback?: (tabId: number, reason: chrome.debugger.DetachReason) => void
|
||||||
|
|
||||||
constructor({ ws, onClose, onTabDetached }: {
|
constructor({ ws, onClose, onTabDetached }: {
|
||||||
ws: WebSocket;
|
ws: WebSocket;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
onTabDetached?: (tabId: number) => void;
|
onTabDetached?: (tabId: number, reason: `${chrome.debugger.DetachReason}`) => void;
|
||||||
}) {
|
}) {
|
||||||
this._ws = ws;
|
this._ws = ws;
|
||||||
this._onCloseCallback = onClose;
|
this._onCloseCallback = onClose;
|
||||||
@@ -197,6 +197,7 @@ export class RelayConnection {
|
|||||||
debugLog('Connection closing, attached tabs count:', this._attachedTabs.size);
|
debugLog('Connection closing, attached tabs count:', this._attachedTabs.size);
|
||||||
this._closed = true;
|
this._closed = true;
|
||||||
|
|
||||||
|
|
||||||
chrome.debugger.onEvent.removeListener(this._onDebuggerEvent);
|
chrome.debugger.onEvent.removeListener(this._onDebuggerEvent);
|
||||||
chrome.debugger.onDetach.removeListener(this._onDebuggerDetach);
|
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;
|
const tabId = source.tabId;
|
||||||
debugLog('_onDebuggerDetach called for tab:', tabId, 'reason:', reason, 'isAttached:', tabId ? this._attachedTabs.has(tabId) : false);
|
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(`Manual debugger detachment detected for tab ${tabId}: ${reason}`);
|
||||||
debugLog('User closed debugger via Chrome automation bar, calling onTabDetached callback');
|
debugLog('User closed debugger via Chrome automation bar, calling onTabDetached callback');
|
||||||
this._onTabDetachedCallback?.(tabId);
|
this._onTabDetachedCallback?.(tabId, reason);
|
||||||
|
|
||||||
this.detachTab(tabId);
|
this.detachTab(tabId);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user