dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.82k stars 453 forks source link

VS Code debug run session start times out with very long environment variable #5475

Open GabrielLetourneau opened 2 months ago

GabrielLetourneau commented 2 months ago

Is there an existing issue for this?

Describe the bug

In WSL, when I try to debug the Aspire starter project in a VS Code that I launched with a big (30k characters) environment variable in context, projects fail to start.

I get the following in VS Code debug console:

fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)    {"Executable": {"name":"apiservice-rtqjs6rfus"}, "Reconciliation": 2, "error": "Put \"https://localhost:38693/run_session?api-version=2024-04-23\": context deadline exceeded"}
Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler: Error: timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)  {"Executable": {"name":"apiservice-rtqjs6rfus"}, "Reconciliation": 2, "error": "Put \"https://localhost:38693/run_session?api-version=2024-04-23\": context deadline exceeded"}
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler: Error: timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)  {"Executable": {"name":"webfrontend-jjet74s3eo"}, "Reconciliation": 5, "error": "Put \"https://localhost:38693/run_session?api-version=2024-04-23\": context deadline exceeded"}
      timeout of 120 seconds exceeded waiting for the IDE to start a run session; you can set the DCP_IDE_REQUEST_TIMEOUT_SECONDS environment variable to override this timeout (in seconds)    {"Executable": {"name":"webfrontend-jjet74s3eo"}, "Reconciliation": 5, "error": "Put \"https://localhost:38693/run_session?api-version=2024-04-23\": context deadline exceeded"}

Dashboard works. Same project runs fine when launched with dotnet run.

Expected Behavior

VS Code debugging of project resource should work even when long environment variables are set.

Steps To Reproduce

In WSL:

mkdir test
cd test
dotnet new aspire-starter
export AAA=`printf '%*s' 30000 | tr ' ' 'A'`
code .

… then press F5.

Exceptions (if any)

No response

.NET Version info

.NET SDK: Version: 8.0.108 Commit: 665a05cea7 Workload version: 8.0.100-manifests.a22b3d1f

Runtime Environment: OS Name: ubuntu OS Version: 24.04 OS Platform: Linux RID: ubuntu.24.04-x64 Base Path: /usr/lib/dotnet/sdk/8.0.108/

.NET workloads installed: Workload version: 8.0.100-manifests.a22b3d1f [aspire] Installation Source: SDK 8.0.100 Manifest Version: 8.1.0/8.0.100 Manifest Path: /home/gabriel/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.1.0/WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.8 Architecture: x64 Commit: 08338fcaa5

.NET SDKs installed: 8.0.108 [/usr/lib/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

Anything else?

$ code --version
1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
x64

ms-dotnettools.csdevkit: v1.9.55 ms-dotnettools.csharp: v2.39.29

davidfowl commented 2 months ago

@karolz-ms

karolz-ms commented 2 months ago

@tmeschter any thoughts? Could be a limit on the request size for the IDE endpoint?

@GabrielLetourneau any chance of using a temp file for passing this information?

GabrielLetourneau commented 2 months ago

@GabrielLetourneau any chance of using a temp file for passing this information?

My current workaround is to unset those big variables I have in a startcode.sh script, as my .NET projects don’t really need them. It’s just an inconvenience that I have to do that, and I can guess many people won’t know or think about doing that.

I’m using a Nix shell for my project, automated with direnv. The way these tools isolate the shell is essentially by adding and augmenting a bunch of environment variables. Several of those are PATH-type lists of file system references. For instance, I have a 17k characters long PYTHONPATH that’s only there because of me having the Azure CLI (with a few extensions) installed by my flake.nix. My PATH is over 5K char.

Most of those things are not needed by my applicative code per se, some of them eventually could be, in any case it’s much more practical to have them up at all time when I’m developing/devopsing. Unused environment variables shouldn’t cause problems.

GabrielLetourneau commented 2 months ago

A few figures that might be useful:

karolz-ms commented 2 months ago

@GabrielLetourneau thank you, that helps a lot

@davidfowl @mitchdenny DCP has the ability to omit the ambient environment variables when starting an Executable, which would help here, but this ability is not currently exposed via the Aspire app model APIs. Something to consider.