private establishDebugSession()

in src/debugger/cordovaDebugSession.ts [395:439]


    private establishDebugSession(
        attachArgs: ICordovaAttachRequestArgs,
        resolve?: (value?: void | PromiseLike<void> | undefined) => void,
        reject?: (reason?: any) => void
    ): void {
        if (this.cordovaCdpProxy) {
            const attachArguments = this.pwaSessionName === PwaDebugType.Chrome ?
                this.jsDebugConfigAdapter.createChromeDebuggingConfig(
                    attachArgs,
                    this.cdpProxyPort,
                    this.pwaSessionName,
                    this.cordovaSession.getSessionId()
                ) :
                this.jsDebugConfigAdapter.createSafariDebuggingConfig(
                    attachArgs,
                    this.cdpProxyPort,
                    this.pwaSessionName,
                    this.cordovaSession.getSessionId()
                );

            vscode.debug.startDebugging(
                this.workspaceManager.workspaceRoot,
                attachArguments,
                {
                    parentSession: this.vsCodeDebugSession,
                    consoleMode: vscode.DebugConsoleMode.MergeWithParent,
                }
            )
            .then((childDebugSessionStarted: boolean) => {
                if (childDebugSessionStarted) {
                    if (resolve) {
                        resolve();
                    }
                } else {
                    reject(new Error(localize("CannotStartChildDebugSession", "Cannot start child debug session")));
                }
            },
                err => {
                    reject(err);
                }
            );
        } else {
            throw new Error(localize("CannotConnectToDebuggerWorkerProxyOffline", "Cannot connect to debugger worker: Chrome debugger proxy is offline"));
        }
    }