public async launch()

in src/legacyEdge/edgeDebugAdapter.ts [99:173]


    public async launch(args: ILaunchRequestArgs): Promise<void> {
        const port = args.port || 2015;

        // Check if the port is being used by another process
        this.events.emitStepStarted('Launch.CheckWhetherPortOccupied');
        await this._checkPortOccupied(args.address, port);

        return super.launch(args).then(() => {
            let runtimeExecutable: string;
            if (args.runtimeExecutable) {
                const re = findExecutable(args.runtimeExecutable);
                if (!re) {
                    return errors.getNotExistErrorResponse('runtimeExecutable', args.runtimeExecutable);
                }

                runtimeExecutable = re;
            }

            runtimeExecutable = runtimeExecutable || utils.getEdgePath();
            if (!runtimeExecutable) {
                return coreUtils.errP(localize('attribute.edge.missing', "Can't find Microsoft Edge - install it or set the \"runtimeExecutable\" field in the launch config."));
            }

            // Start with remote debugging enabled
            const edgeArgs: string[] = [];
            const edgeEnv: {[key: string]: string} = args.env || null;
            const edgeWorkingDir: string = args.cwd || null;

            if (!args.noDebug) {
                edgeArgs.push('--devtools-server-port');
                edgeArgs.push(port.toString());
            }

            let launchUrl: string;
            if (args.file) {
                launchUrl = coreUtils.pathToFileURL(args.file);
            } else if (args.url) {
                launchUrl = args.url;
            }
            if (launchUrl) {
                // We store the launch file/url provided by the user and temporarily launch and attach to a custom landing page using file url.
                // Once we receive configurationDone() event, we redirect the page to the user file/url
                // This is done to facilitate hitting breakpoints on load and to solve timeout issues
                this._userRequestedUrl = launchUrl;
                // The compiled file lives in root/out/src while the landingPage will live in root/
                /* So when this script is getting executed from the %programdata% directory under EdgeAdapter/out/src, we need to find the
                landingPage under EdgeAdapter/ hence we need to go 2 directories up */
                let landingPagePath = path.dirname(path.dirname(path.dirname(__dirname)));
                launchUrl = encodeURI('file:///' + landingPagePath + '/landingPage.html');
                this._breakOnLoadActive = true;

                edgeArgs.push(launchUrl);
            }

            this._edgeProc = this.spawnEdge(runtimeExecutable, edgeArgs, edgeEnv, edgeWorkingDir, !!args.runtimeExecutable);
            this._edgeProc.on('error', (err) => {
                const errMsg = 'Chrome error: ' + err;
                logger.error(errMsg);
                this.terminateSession(errMsg);
            });

            return args.noDebug ? undefined :
                this.doAttach(port, launchUrl || args.urlFilter, args.address, args.timeout, undefined, args.extraCRDPChannelPort)
                .then(() => {
                    this._scriptParsedEventBookKeeping = {};
                    this._debugProxyPort = port;

                    if (!this._chromeConnection.isAttached || !this._chromeConnection.attachedTarget) {
                        throw coreUtils.errP(localize('edge.debug.error.notattached', 'Debugging connection is not attached after the attaching process.'));
                    }

                    this._debuggerId = this._chromeConnection.attachedTarget.id;
                });
        });
    }