Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/commands/pickFuncProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as vscode from 'vscode';
import { hostStartTaskName } from '../constants';
import { preDebugValidate, type IPreDebugValidateResult } from '../debug/validatePreDebug';
import { ext } from '../extensionVariables';
import { buildPathToWorkspaceFolderMap, getFuncPortFromTaskOrProject, isFuncHostTask, runningFuncTaskMap, stopFuncTaskIfRunning, type IRunningFuncTask } from '../funcCoreTools/funcHostTask';
import { buildPathToWorkspaceFolderMap, getFuncPortFromTaskOrProject, isFuncHostTask, resolveAndNormalizeCwd, runningFuncTaskMap, stopFuncTaskIfRunning, type IRunningFuncTask } from '../funcCoreTools/funcHostTask';
import { localize } from '../localize';
import { delay } from '../utils/delay';
import { requestUtils } from '../utils/requestUtils';
Expand Down Expand Up @@ -134,10 +134,11 @@ export async function pickFuncProcess(context: IActionContext, debugConfig: vsco
async function waitForPrevFuncTaskToStop(workspaceFolder: vscode.WorkspaceFolder, buildPath?: string): Promise<void> {
await stopFuncTaskIfRunning(workspaceFolder, buildPath);

const normalizedBuildPath = resolveAndNormalizeCwd(workspaceFolder, buildPath);
const timeoutInSeconds: number = 30;
const maxTime: number = Date.now() + timeoutInSeconds * 1000;
while (Date.now() < maxTime) {
if (!runningFuncTaskMap.has(workspaceFolder)) {
if (!runningFuncTaskMap.has(workspaceFolder, normalizedBuildPath)) {
return;
}
await delay(1000);
Expand Down Expand Up @@ -178,7 +179,7 @@ async function startFuncTask(context: IActionContext, workspaceFolder: vscode.Wo
throw taskError;
}

const taskInfo: IRunningFuncTask | undefined = runningFuncTaskMap.get(workspaceFolder, buildPath);
const taskInfo: IRunningFuncTask | undefined = runningFuncTaskMap.get(workspaceFolder, resolveAndNormalizeCwd(workspaceFolder, buildPath));
if (taskInfo) {
for (const scheme of ['http', 'https']) {
const statusRequest: AzExtRequestPrepareOptions = { url: `${scheme}://localhost:${funcPort}/admin/host/status`, method: 'GET' };
Expand Down
2 changes: 1 addition & 1 deletion src/debug/nodes/HostErrorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class HostErrorNode {
public readonly kind = 'hostError' as const;

constructor(
public readonly workspaceFolder: vscode.WorkspaceFolder | vscode.TaskScope,
public readonly workspaceFolder: vscode.WorkspaceFolder,
public readonly portNumber: string,
public readonly message: string,
public readonly cwd?: string,
Expand Down
8 changes: 4 additions & 4 deletions src/debug/nodes/HostTaskNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { runningFuncTaskMap } from '../../funcCoreTools/funcHostTask';
import { resolveAndNormalizeCwd, runningFuncTaskMap } from '../../funcCoreTools/funcHostTask';
import { buildHostTooltip, formatTimestamp, getScopeLabel } from './funcHostDebugUtils';
import { HostErrorNode } from './HostErrorNode';

export class HostTaskNode {
public readonly kind = 'hostTask' as const;

constructor(
public readonly workspaceFolder: vscode.WorkspaceFolder | vscode.TaskScope,
public readonly workspaceFolder: vscode.WorkspaceFolder,
public readonly portNumber: string,
public readonly startTime: Date,
public readonly cwd?: string,
) { }

public getTreeItem(): vscode.TreeItem {
const task = runningFuncTaskMap.get(this.workspaceFolder, this.cwd);
const task = runningFuncTaskMap.get(this.workspaceFolder, resolveAndNormalizeCwd(this.workspaceFolder, this.cwd));
const scopeLabel = getScopeLabel(this.workspaceFolder);
const label = `${scopeLabel} (${this.portNumber})`;

Expand All @@ -34,7 +34,7 @@ export class HostTaskNode {
}

public getChildren(): HostErrorNode[] {
const task = runningFuncTaskMap.get(this.workspaceFolder, this.cwd);
const task = runningFuncTaskMap.get(this.workspaceFolder, resolveAndNormalizeCwd(this.workspaceFolder, this.cwd));
const errors = task?.errorLogs ?? [];
return errors
.slice()
Expand Down
6 changes: 2 additions & 4 deletions src/debug/nodes/funcHostDebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ export function formatTimestamp(date: Date): string {
return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit' });
}

export function getScopeLabel(scope: vscode.WorkspaceFolder | vscode.TaskScope): string {
return typeof scope === 'object'
? scope.name
: localize('funcHostDebug.globalScope', 'Global');
export function getScopeLabel(scope: vscode.WorkspaceFolder): string {
return scope.name;
}

export function buildHostTooltip(opts: { label: string; scopeLabel: string; portNumber: string; startTime: Date; stopTime?: Date; cwd?: string; pid?: number }): vscode.MarkdownString {
Expand Down
8 changes: 4 additions & 4 deletions src/debug/registerFunctionHostDebugView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { registerCommand, type IActionContext } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { getRecentLogsPlainText } from '../funcCoreTools/funcHostErrorUtils';
import { clearStoppedSessions, onRunningFuncTasksChanged, runningFuncTaskMap, type IRunningFuncTask } from '../funcCoreTools/funcHostTask';
import { clearStoppedSessions, onRunningFuncTasksChanged, resolveAndNormalizeCwd, runningFuncTaskMap, type IRunningFuncTask } from '../funcCoreTools/funcHostTask';
import { localize } from '../localize';
import { stripAnsiControlCharacters } from '../utils/ansiUtils';
import { FuncHostDebugViewProvider, HostErrorNode, HostTaskNode, StoppedHostNode } from './FunctionHostDebugView';
Expand Down Expand Up @@ -40,7 +40,7 @@ function getNodeContext(args: unknown): { scopeLabel: string; portNumber: string
errorOutput: stripAnsiControlCharacters(args.message).trim() || args.message,
};
} else if (isHostTaskNode(args)) {
const task = runningFuncTaskMap.get(args.workspaceFolder, args.cwd);
const task = runningFuncTaskMap.get(args.workspaceFolder, resolveAndNormalizeCwd(args.workspaceFolder, args.cwd));
return {
scopeLabel: getScopeLabel(args.workspaceFolder),
portNumber: args.portNumber,
Expand Down Expand Up @@ -109,7 +109,7 @@ export function registerFunctionHostDebugView(context: vscode.ExtensionContext):
registerCommand('azureFunctions.funcHostDebug.copyRecentLogs', async (actionContext: IActionContext, args: unknown) => {
actionContext.telemetry.properties.source = 'funcHostDebugView';
if (isHostTaskNode(args)) {
const task = runningFuncTaskMap.get(args.workspaceFolder, args.cwd);
const task = runningFuncTaskMap.get(args.workspaceFolder, resolveAndNormalizeCwd(args.workspaceFolder, args.cwd));
const text = getRecentLogsPlainText(task);
await vscode.env.clipboard.writeText(text);
} else if (isStoppedHostNode(args)) {
Expand All @@ -122,7 +122,7 @@ export function registerFunctionHostDebugView(context: vscode.ExtensionContext):
actionContext.telemetry.properties.source = 'funcHostDebugView';
let text: string | undefined;
if (isHostTaskNode(args)) {
const task = runningFuncTaskMap.get(args.workspaceFolder, args.cwd);
const task = runningFuncTaskMap.get(args.workspaceFolder, resolveAndNormalizeCwd(args.workspaceFolder, args.cwd));
text = getRecentLogsPlainText(task);
} else if (isStoppedHostNode(args)) {
text = getRecentLogsPlainText(args.stoppedTask);
Expand Down
Loading
Loading