Skip to content

Commit 6b036fb

Browse files
committed
Keep track of whether func task is running for pickProcess (#575)
I incorrectly made the assumption that `vscode.tasks.taskExecutions` was the list of _running_ tasks, but it's actually a list of tasks that have _ever_ run in this session, even if they're not running right now.
1 parent 631a368 commit 6b036fb

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
All notable changes to the "azurefunctions" extension will be documented in this file.
66

7+
## 0.10.2 - 2018-09-10
8+
9+
### Fixed
10+
11+
- Debugging C# functions after fixing a build break fails with error "Failed to stop previous running Functions host..." [#534](https://github.com/Microsoft/vscode-azurefunctions/issues/534)
12+
713
## 0.10.1 - 2018-09-06
814

915
### Added

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-azurefunctions",
33
"displayName": "Azure Functions",
44
"description": "%extension.description%",
5-
"version": "0.10.1",
5+
"version": "0.10.2",
66
"publisher": "ms-azuretools",
77
"icon": "resources/azure-functions.png",
88
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
@@ -644,7 +644,7 @@
644644
"request-promise": "^4.2.2",
645645
"semver": "^5.5.0",
646646
"vscode-azureappservice": "^0.21.0",
647-
"vscode-azureextensionui": "^0.17.0",
647+
"vscode-azureextensionui": "^0.17.4",
648648
"vscode-azurekudu": "^0.1.8",
649649
"vscode-extension-telemetry": "^0.0.18",
650650
"vscode-nls": "^2.0.2",

src/commands/pickFuncProcess.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as vscode from 'vscode';
77
import { Task, TaskExecution } from 'vscode';
8+
import { ext } from 'vscode-azureappservice/lib/extensionVariables';
89
import { IActionContext, UserCancelledError } from 'vscode-azureextensionui';
910
import { extensionPrefix, isWindows } from '../constants';
1011
import { validateFuncCoreToolsInstalled } from '../funcCoreTools/validateFuncCoreToolsInstalled';
@@ -13,6 +14,21 @@ import { getFuncExtensionSetting } from '../ProjectSettings';
1314
import { tryFetchNodeModule } from '../utils/tryFetchNodeModule';
1415
import { funcHostTaskLabel } from './createNewProject/IProjectCreator';
1516

17+
let isFuncTaskRunning: boolean = false;
18+
export function initPickFuncProcess(): void {
19+
ext.context.subscriptions.push(vscode.tasks.onDidEndTask((e: vscode.TaskEndEvent) => {
20+
if (isFuncTask(e.execution.task)) {
21+
isFuncTaskRunning = false;
22+
}
23+
}));
24+
25+
ext.context.subscriptions.push(vscode.tasks.onDidStartTask((e: vscode.TaskEndEvent) => {
26+
if (isFuncTask(e.execution.task)) {
27+
isFuncTaskRunning = true;
28+
}
29+
}));
30+
}
31+
1632
export async function pickFuncProcess(actionContext: IActionContext): Promise<string | undefined> {
1733
if (!await validateFuncCoreToolsInstalled(true /* forcePrompt */)) {
1834
throw new UserCancelledError();
@@ -49,7 +65,7 @@ function isFuncTask(task: Task): boolean {
4965

5066
async function stopFuncTaskIfRunning(): Promise<void> {
5167
const funcExecution: TaskExecution | undefined = vscode.tasks.taskExecutions.find((te: TaskExecution) => isFuncTask(te.task));
52-
if (funcExecution) {
68+
if (funcExecution && isFuncTaskRunning) {
5369
const waitForEndPromise: Promise<void> = new Promise((resolve: () => void, reject: (e: Error) => void): void => {
5470
const listener: vscode.Disposable = vscode.tasks.onDidEndTask((e: vscode.TaskEndEvent) => {
5571
if (isFuncTask(e.execution.task)) {

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ILogStreamTreeItem } from './commands/logstream/ILogStreamTreeItem';
2929
import { startStreamingLogs } from './commands/logstream/startStreamingLogs';
3030
import { stopStreamingLogs } from './commands/logstream/stopStreamingLogs';
3131
import { openInPortal } from './commands/openInPortal';
32-
import { pickFuncProcess } from './commands/pickFuncProcess';
32+
import { initPickFuncProcess, pickFuncProcess } from './commands/pickFuncProcess';
3333
import { remoteDebugFunctionApp } from './commands/remoteDebugFunctionApp';
3434
import { renameAppSetting } from './commands/renameAppSetting';
3535
import { restartFunctionApp } from './commands/restartFunctionApp';
@@ -124,6 +124,8 @@ export function activate(context: vscode.ExtensionContext): void {
124124
registerCommand('azureFunctions.debugFunctionAppOnAzure', async (node?: IAzureNode<FunctionAppTreeItem>) => await remoteDebugFunctionApp(outputChannel, ui, tree, node));
125125
registerCommand('azureFunctions.deleteProxy', async (node?: IAzureNode) => await deleteNode(tree, ProxyTreeItem.contextValue, node));
126126
registerCommand('azureFunctions.uninstallFuncCoreTools', async () => await uninstallFuncCoreTools());
127+
128+
initPickFuncProcess();
127129
});
128130
}
129131

0 commit comments

Comments
 (0)