Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks (and TaskExecutions) are not === in the onDid(Start|End)Task callbacks. #96643

Open
ashgti opened this issue Apr 29, 2020 · 8 comments
Open
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug tasks Task system issues
Milestone

Comments

@ashgti
Copy link
Contributor

ashgti commented Apr 29, 2020

  • VSCode Version: 1.44.2
  • OS Version: macOS 10.5.4

Steps to Reproduce:

  1. Create a new extension using yo code.
  2. Add the following to the 'activate' function body:
	let disposable = vscode.commands.registerCommand('extension.helloWorld', async () => {
		let echoTask = new vscode.Task({type: "taskbug"}, vscode.TaskScope.Workspace, 'echo', 'taskbug', new vscode.ProcessExecution('/bin/echo', ['hello world']));

		const echoTaskExecution = await vscode.tasks.executeTask(echoTask);

		vscode.tasks.onDidStartTaskProcess(e => {
			if (e.execution === echoTaskExecution) {
				console.log(`Detected that my task started with pid ${e.processId}`);
			} else if (e.execution.task === echoTask) {
				console.log(`Detected that my task started with pid ${e.processId}`);
			}
		});

		vscode.tasks.onDidEndTaskProcess(e => {
			if (e.execution === echoTaskExecution) {
				console.log(`Detected that my task exited with exit code ${e.exitCode}`);
			} else if (e.execution.task === echoTask) {
				console.log(`Detected that my task exited with exit code ${e.exitCode}`);
			}
		});
	});
  1. Run debug the extension and run the 'Hello World' command.

If you break inside the onDidStartTaskProcess and onDidEndTaskProcess that comparison fail, which means its difficult to determine when the task starts or ends.

It's worth noting that in VSCode 1.43 the above comparisons both work, but in 1.44 this is not working.

Does this issue occur when all extensions are disabled?: Yes

@ashgti
Copy link
Contributor Author

ashgti commented Apr 29, 2020

I also checked Insiders for 1.45 and it also fails to compare the Task and TaskExecution objects in onDid(Start|End)TaskProcess callbacks.

@ashgti
Copy link
Contributor Author

ashgti commented Apr 29, 2020

Related bug for TaskExecutions being comparable #47465

@alexr00 alexr00 self-assigned this Apr 30, 2020
@alexr00 alexr00 added the tasks Task system issues label Apr 30, 2020
@alexr00 alexr00 added this to the May 2020 milestone Apr 30, 2020
@alexr00 alexr00 added the bug Issue identified by VS Code Team member as probable bug label Apr 30, 2020
@alexr00 alexr00 modified the milestones: May 2020, April 2020 Apr 30, 2020
@ThadHouse
Copy link

This bug actually completely broke our extension. Is the milestone to fix this still May 2020? This is very blocking, especially since otherwise there is no way to wait for a task to be done and then do something with the result of that task.

@alexr00
Copy link
Member

alexr00 commented May 25, 2020

@ashgti and @ThadHouse I have pushed a fix that solves the task executions not being equal. If you can, please install the insiders build tomorrow and verify that the issue you were seeing is resolved. If you still see a problem with the next insiders build, please let me know as soon as possible so I can have time to fix it before the next release.

@ashgti
Copy link
Contributor Author

ashgti commented May 26, 2020

Works for me! Thanks!

@badsyntax
Copy link
Contributor

Related to bug #98080

I've also verified this change fixes that bug. Thanks 👍

@alexr00 can i ask why there are no tests for this change? it would be useful to add tests to prevent regressions.

badsyntax added a commit to microsoft/vscode-gradle that referenced this issue Jun 10, 2020
badsyntax added a commit to microsoft/vscode-gradle that referenced this issue Jun 10, 2020
alexr00 added a commit that referenced this issue Jun 11, 2020
@alexr00
Copy link
Member

alexr00 commented Jun 11, 2020

Added an API test.

@badsyntax
Copy link
Contributor

badsyntax commented Jun 15, 2020

After moving some code around in my extension, i'm seeing the race condition again. I've added some details to #98080 (comment)

@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2020
@meganrogge meganrogge reopened this Jul 1, 2022
@alexr00 alexr00 assigned meganrogge and unassigned alexr00 Dec 7, 2022
@meganrogge meganrogge removed the verified Verification succeeded label Dec 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug tasks Task system issues
Projects
None yet
Development

No branches or pull requests

6 participants