Path: blob/main/src/vs/workbench/contrib/mcp/electron-browser/mcpDevModeDebuggingNode.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { timeout } from '../../../../base/common/async.js';6import { ICommandService } from '../../../../platform/commands/common/commands.js';7import { INativeHostService } from '../../../../platform/native/common/native.js';8import { IDebugService } from '../../debug/common/debug.js';9import { McpDevModeDebugging } from '../common/mcpDevMode.js';1011export class McpDevModeDebuggingNode extends McpDevModeDebugging {12constructor(13@IDebugService debugService: IDebugService,14@ICommandService commandService: ICommandService,15@INativeHostService private readonly _nativeHostService: INativeHostService,16) {17super(debugService, commandService);18}1920protected override async ensureListeningOnPort(port: number): Promise<void> {21const deadline = Date.now() + 30_000;22while (await this._nativeHostService.isPortFree(port) && Date.now() < deadline) {23await timeout(50);24}25}2627protected override getDebugPort() {28return this._nativeHostService.findFreePort(5000, 10 /* try 10 ports */, 5000 /* try up to 5 seconds */, 2048 /* skip 2048 ports between attempts */);29}30}313233