Skip to content

Commit 0e5c011

Browse files
committed
fix task reconnection
1 parent b2ab524 commit 0e5c011

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
4747
import { ITerminalGroupService, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
4848
import { ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
4949

50-
import { ConfiguringTask, ContributedTask, CustomTask, ExecutionEngine, InMemoryTask, ITaskEvent, ITaskIdentifier, ITaskSet, JsonSchemaVersion, KeyedTaskIdentifier, RuntimeType, Task, TaskDefinition, TaskEventKind, TaskGroup, TaskRunSource, TaskSettingId, TaskSorter, TaskSourceKind, TasksSchemaProperties, TASK_RUNNING_STATE, USER_TASKS_GROUP_KEY } from 'vs/workbench/contrib/tasks/common/tasks';
50+
import { ConfiguringTask, ContributedTask, CustomTask, ExecutionEngine, InMemoryTask, ITaskEvent, ITaskIdentifier, ITaskSet, JsonSchemaVersion, KeyedTaskIdentifier, RuntimeType, Task, TASK_RUNNING_STATE, TaskDefinition, TaskEventKind, TaskGroup, TaskRunSource, TaskSettingId, TaskSorter, TaskSourceKind, TasksSchemaProperties, USER_TASKS_GROUP_KEY } from 'vs/workbench/contrib/tasks/common/tasks';
5151
import { CustomExecutionSupportedContext, ICustomizationProperties, IProblemMatcherRunOptions, ITaskFilter, ITaskProvider, ITaskService, IWorkspaceFolderTaskResult, ProcessExecutionSupportedContext, ServerlessWebContext, ShellExecutionSupportedContext, TaskCommandsRegistered, TaskExecutionSupportedContext } from 'vs/workbench/contrib/tasks/common/taskService';
5252
import { ITaskExecuteResult, ITaskResolver, ITaskSummary, ITaskSystem, ITaskSystemInfo, ITaskTerminateResponse, TaskError, TaskErrors, TaskExecuteKind } from 'vs/workbench/contrib/tasks/common/taskSystem';
5353
import { getTemplates as getTaskTemplates } from 'vs/workbench/contrib/tasks/common/taskTemplates';
@@ -60,15 +60,18 @@ import { IQuickInputService, IQuickPick, IQuickPickItem, IQuickPickSeparator, Qu
6060
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
6161
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
6262

63+
import { raceTimeout } from 'vs/base/common/async';
6364
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
6465
import { once } from 'vs/base/common/functional';
6566
import { toFormattedString } from 'vs/base/common/jsonFormatter';
6667
import { Schemas } from 'vs/base/common/network';
68+
import { ThemeIcon } from 'vs/base/common/themables';
6769
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
6870
import { TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor';
71+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
6972
import { ILogService } from 'vs/platform/log/common/log';
73+
import { TerminalExitReason } from 'vs/platform/terminal/common/terminal';
7074
import { IThemeService } from 'vs/platform/theme/common/themeService';
71-
import { ThemeIcon } from 'vs/base/common/themables';
7275
import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust';
7376
import { VirtualWorkspaceContext } from 'vs/workbench/common/contextkeys';
7477
import { EditorResourceAccessor, SaveReason } from 'vs/workbench/common/editor';
@@ -79,10 +82,7 @@ import { ILifecycleService, ShutdownReason, StartupKind } from 'vs/workbench/ser
7982
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
8083
import { IPathService } from 'vs/workbench/services/path/common/pathService';
8184
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
82-
import { TerminalExitReason } from 'vs/platform/terminal/common/terminal';
8385
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
84-
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
85-
import { raceTimeout } from 'vs/base/common/async';
8686

8787
const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
8888
const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt';
@@ -224,7 +224,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
224224
protected _outputChannel: IOutputChannel;
225225
protected readonly _onDidStateChange: Emitter<ITaskEvent>;
226226
private _waitForSupportedExecutions: Promise<void>;
227+
private _waitForAllSupportedExecutions: Promise<void>;
227228
private _onDidRegisterSupportedExecutions: Emitter<void> = new Emitter();
229+
private _onDidRegisterAllSupportedExecutions: Emitter<void> = new Emitter();
228230
private _onDidChangeTaskSystemInfo: Emitter<void> = new Emitter();
229231
private _willRestart: boolean = false;
230232
public onDidChangeTaskSystemInfo: Event<void> = this._onDidChangeTaskSystemInfo.event;
@@ -336,6 +338,9 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
336338
this._waitForSupportedExecutions = new Promise(resolve => {
337339
once(this._onDidRegisterSupportedExecutions.event)(() => resolve());
338340
});
341+
this._waitForAllSupportedExecutions = new Promise(resolve => {
342+
once(this._onDidRegisterAllSupportedExecutions.event)(() => resolve());
343+
});
339344
if (this._terminalService.getReconnectedTerminals('Task')?.length) {
340345
this._attemptTaskReconnection();
341346
} else {
@@ -2202,6 +2207,11 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
22022207
return new Map();
22032208
}
22042209
await this._waitForSupportedExecutions;
2210+
if (runSource === TaskRunSource.Reconnect) {
2211+
await raceTimeout(this._waitForAllSupportedExecutions, 3000, () => {
2212+
console.warn('Timed out waiting for all supported executions for task reconnection');
2213+
});
2214+
}
22052215
await this._whenTaskSystemReady;
22062216
if (this._workspaceTasksPromise) {
22072217
return this._workspaceTasksPromise;

0 commit comments

Comments
 (0)