microsoft / vscode-tye

A Visual Studio Code extension for Tye development
Other
25 stars 9 forks source link

The debugger isn't attached with an error "The Tye application 'microservice' is not running" after F5ing using the "Debug with Tye" configuration #170

Open v-xinda opened 2 years ago

v-xinda commented 2 years ago

OS: Win10 Build Version: 20211202.1 Tye Version: 0.11.0-alpha.21616.1 Regression: Not a regression

Repro Steps:

  1. Download the application by the command "git clone https://github.com/pratiksanglikar/tye-demo" -> Open the application in VS Code.
  2. Run application.
  3. Select the Debug with Tye configuration and press F5 to start debugging.
  4. Check whether the debugger is attached.

Expect: The debugger is attached.

Actual: The debugger isn't attached with an error. image

More Info:

  1. This issue doesn't reproduce when Tye version is 0.10.0-alpha.21420.1.
  2. This issue doesn't reproduce when clicking "Attach" icon next to application.
philliphoff commented 2 years ago

@v-xinda I'm not able to reproduce this on Windows. Is this an intermittent issue, or does it reproduce every time?

v-xinda commented 2 years ago

@philliphoff Verified on the current release version on Windows, this issue reproduces every time. It needs to wait about one minute. Dotnet Version: 6.0.302 Tye Version: 0.12.0-aipha.22277.1

philliphoff commented 2 years ago

@v-xinda Thanks for the information. What hardware are you running Tye one? I'm curious if it might be a timing issue that I'm not seeing (given I have a pretty beefy PC).

v-xinda commented 2 years ago

@philliphoff Windows machine hardware details as below: Device name: vxinda004dxe Full device name: vxinda004dxe.redmond.corp.microsoft.com Processor: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz 2.10 GHz Installed RAM: 8.00 GB Device ID: F929A990-971A-4827-B118-0F5E91515F6E Product ID: 00329-00000-00003-AA347 System type: 64-bit operating system, x64-based processor Pen and touch: No pen or touch input is available for this display Edition: Windows 10 Enterprise Version: 21H2 OS build: 19044.1826 Experience: Windows Feature Experience Pack 120.2212.4170.0

rainman-306 commented 2 years ago

Have the same basic issue, here are my repo steps.

OS: Windows 11 Pro 10.0.22000 Processor: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz, 1498 Mhz, 4 Core(s), 8 Logical Processor(s) Installed Physical Memory (RAM) 32.0 GB Available Physical Memory 16.3 GB

Tye Version: 0.11.0-alpha.22111.1

Repro Steps:

In terminal: dotnet new webapi code .

In VS Code open command palette: Tye: Initialize Tye Tye: Scaffold Tye Tasks

Select Debug with Tye & press play button.

Expect: Debugger is attached.

Actual: The debugger isn't attached, shows following error: image

Terminal Output: Loading Application Details... Launching Tye Host...

[15:54:01 INF] Executing application from c:\Users\TestUser\source\repos\TyeExp3\tye.yaml [15:54:02 INF] Dashboard running on http://127.0.0.1:8000 [15:54:03 INF] removed process 19956 from previous run [15:54:03 INF] Build Watcher: Watching for builds... [15:54:03 INF] Building projects [15:54:04 INF] Application tyeexp3 started successfully with Pid: 19704 [15:54:04 INF] Launching service service1_df6e648e-9: c:\Users\TestUser\source\repos\TyeExp3\src\service1\bin\Debug\net6.0\service1.exe [15:54:05 INF] service1_df6e648e-9 running on process id 20736 bound to http://localhost:54053, https://localhost:54054 [15:54:05 INF] Replica service1_df6e648e-9 is moving to a ready state [15:54:05 INF] watch: service1_df6e648e-9 Started [15:54:05 INF] Selected process 20736. [15:54:05 INF] Listening for event pipe events for service1_df6e648e-9 on process id 20736

Tried this on 2 different machines, the results were the same on both machines. I can access the Tye Dashboard, the WebAPI app, the WebAPI swagger, able to get response from http://[localhost:8000/api/v1](http://localhost:8000/api/v1)

Is there a way to collect verbose logs for the extension?

rainman-306 commented 2 years ago

I pulled the source for version 0.5.1 and debugged the issue on my device, here's what I'm seeing.

After I launch the tye-run task in VSCode (Extension Development Host), I watched the various commands being executed via process.ts, break point on line 119.

See Tye version being queried: VersionWithStackTrace

Then WMI query to get the Tye process before it has started: GetProcessBeforeAndStackTrace I would have expected data to be an empty string when tye.exe wasn't running, but it's returning the VSCode path. Depending on how quickly the tye process is started I will see this executed multiple times, each time it returns the VSCode path.

Starting the Tye process: TyeRunWithStack

Then WMI query to get the Tye process after it's started: GetProcessAfterWithStack

The issue is the data contains the path for VSCode when the WMI query is executed.

if (process.stdout) {
    process.stdout.on(
        'data',
        (data: string | Buffer) => {
            this.onStdOutEmitter.fire(data.toString());
        });
}

On my device it prepends the VSCode path every time the WMI query is made, and this is causing the JSON.parse to fail in processProvider.ts; so no Tye apps are found.

rainman-306 commented 2 years ago

Did a bit more digging and I was able to reproduce the issue with just a simple node.js app:

With tye running, this code

const { exec } = require('child_process');

var command = `Get-WmiObject -Query "select CommandLine, Name, ProcessId from win32_process where Name='tye' or Name='tye.exe'" | Select-Object -Property CommandLine, Name, ProcessId | ConvertTo-Json`;

const ls = exec(command, {shell:'powershell.exe'}, function (error, stdout, stderr) {
  if (error) {
    console.log(error.stack);
    console.log('Error code: ' + error.code);
    console.log('Signal received: ' + error.signal);
  }
  console.log('Child Process STDOUT: ' + stdout);
  console.log('Child Process STDERR: ' + stderr);
});

ls.on('exit', function (code) {
  console.log('Child process exited with exit code ' + code);
});

produces this output:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe .\home.js
(node:3536) [INSPECTOR_ASYNC_STACK_TRACES_NOT_AVAILABLE] Warning: Warning: Async stack traces in debugger are not available on 32bit platforms. The feature is disabled.
(Use `node --trace-warnings ...` to show where the warning was created)
Child process exited with exit code 0
Child Process STDOUT: C:\Stash\Frameworks\vscode-tye\rainNode
{
    "CommandLine":  "\"C:\\Users\\testUser\\.dotnet\\tools\\tye.exe\" run",
    "Name":  "tye.exe",
    "ProcessId":  34000
}
Child Process STDERR:

Without tye running, I get this output:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe .\home.js
(node:29060) [INSPECTOR_ASYNC_STACK_TRACES_NOT_AVAILABLE] Warning: Warning: Async stack traces in debugger are not available on 32bit platforms. The feature is disabled.
(Use `node --trace-warnings ...` to show where the warning was created)
internal/process/warning:50
Child process exited with exit code 0
home.js:16
Child Process STDOUT: C:\Stash\Frameworks\vscode-tye\rainNode

home.js:11
Child Process STDERR: 

In both cases the host directory where the code resides is sent to the STDOUT C:\Stash\Frameworks\vscode-tye\rainNode.

v-xinda commented 1 year ago

Verified this issue with the latest build 20230320.1, it still reproduces now.

nitish-kaushik commented 9 months ago

I fixed the error by opening a CLI tool at the root level (The same as where we have tye.yaml file) and running the tye run --watch command

Earlier I was getting this error The tye application is not running while running it from VS Code.