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

NPM tasks with a path have an extra character in the path #146165

Closed
Ark-kun opened this issue Mar 28, 2022 · 4 comments
Closed

NPM tasks with a path have an extra character in the path #146165

Ark-kun opened this issue Mar 28, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tasks Task system issues verified Verification succeeded
Milestone

Comments

@Ark-kun
Copy link

Ark-kun commented Mar 28, 2022

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

  • VS Code Version: 1.65.2
  • OS Version: Windows_NT x64 10.0.18363

Steps to Reproduce:

  1. Create empty directory with an extension subdirectory
  2. Add workspace with two folder paths - . and ./extension/
  3. Put the official VSCode Extension webview sample in the extension subdirectory https://github.com/microsoft/vscode-extension-samples/tree/0d36653/webview-sample
  4. cd extension && npm ci
  5. Open the workspace in VSCode
  6. Press F5 to start debugging
  7. ! Debugging spins, but never starts (new VSCode window never opens).

Why?
9. extension/tasks.json customizes npm watch to be a background task: "isBackground": true,. launch.json has "preLaunchTask": "npm: watch", but it ignores tasks.json and just runs npm watch without customization.
10. Next we show that launch.json actually knows about tasks.json, but ignores it. Add label to the task: "label": "SomeTaskLabel", and specify that label in launch.json: "preLaunchTask": "SomeTaskLabel".
11. Stop all tasks and press F5 again
12. The debugging session launches correctly

This demonstrates that launch.json can correctly reference task configuration from tasks.json, but decides to ignore it.

P.S. I spent several hours pulling out my hair and I wish VSCode was less ambiguous and did not silently ignore configurations. It should be clear whether the preLaunchTask references a task or an npm script.

P.P.S. This area has more questionable design:
If the task has "path": "123" (but no label), then the following launch setting surprisingly makes things work: "preLaunchTask": "npm: watch - 12". Note that the last character 3 needs to be cut off. This is really a WTF-type behavior. And when using "path": "." you need "preLaunchTask": "npm: watch - " (note the trailing space).

This "preLaunchTask": "npm: watch - <task path with last character cut off>" format is confusing not described anywhere. I prefer proper structure instead of a string with unknown format.

@alexr00
Copy link
Member

alexr00 commented Mar 28, 2022

@Ark-kun Does this match your workspace setup?

image

When I F5'd the prelaunch task ran correctly as a background task.

@alexr00 alexr00 added the info-needed Issue requires more information from poster label Mar 28, 2022
@Ark-kun
Copy link
Author

Ark-kun commented Mar 29, 2022

@alexr00 Thank you for trying to reproduce the issue. Your workspace setup seems to be identical to what I had.

Prior to reporting this issue I've isolated and created a PoC repo identical to the one that you have to validate the bug and experiment with solutions. My setup was triggering the issue reliable despite restarting VSCode, so I assumed that the repro rate was 100%. Unfortunately, it did not occur to me to record a video.
After reading your comment, I've opened the repo again and I must admit that today the same PoC repo started working correctly. I'm not sure what happened.

My second issue (wrong auto-generated task label) is still there, but I should probably create a separate issue for that:

image

Thank you again.

@alexr00
Copy link
Member

alexr00 commented Mar 29, 2022

I can repro, and that's definitely a bug. Let's repurpose this issue for the the path bug.

@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug tasks Task system issues and removed info-needed Issue requires more information from poster labels Mar 29, 2022
@alexr00 alexr00 added this to the April 2022 milestone Mar 29, 2022
@alexr00 alexr00 changed the title launch.json preLaunchTask ignores configuration from tasks.json when those files are in a subdirectory NPM tasks with a path have an extra character in the path Mar 29, 2022
@alexr00
Copy link
Member

alexr00 commented Mar 29, 2022

Repro:

  1. Clone microsoft/vscode-extension-samples
  2. "Tasks: Configure task" and chose npm: compile - helloworld-sample.
  3. 🐛 the path in the configured task ends in a slash.

@sandy081 sandy081 added the verified Verification succeeded label Apr 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 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 insiders-released Patch has been released in VS Code Insiders tasks Task system issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants
@Ark-kun @weinand @sandy081 @alexr00 and others