getgauge / gauge-dotnet

C# runner for gauge + DotNet standard 6.0-8.0
Apache License 2.0
27 stars 21 forks source link

Error: Timed out connecting to dotnet #196

Closed scott-brady closed 1 month ago

scott-brady commented 1 year ago

When running gauge run specs, the command intermittently fails with an error similar to the following:

[Gauge]
Failed to start gauge API: Timed out connecting to dotnet
Get Support ----------------------------
    Docs:          https://docs.gauge.org
    Bugs:          https://github.com/getgauge/gauge/issues
    Chat:          https://spectrum.chat/gauge
Your Environment Information -----------
        linux, 1.5.4, 30a0c23
        dotnet (0.5.1), html-report (4.2.0), xml-report (0.4.0)

This has been reproduced on multiple projects, including the template project generated by gauge init dotnet.

Environment Info

# gauge version
Gauge version: 1.5.4
Commit Hash: 30a0c23

Plugins
-------
dotnet (0.5.1)
html-report (4.2.0)
screenshot (0.1.0)
# dotnet --info
.NET SDK:
 Version:   7.0.400
 Commit:    73bf45718d

Runtime Environment:
 OS Name:     debian
 OS Version:  11
 OS Platform: Linux
 RID:         debian.11-arm64
 Base Path:   /home/vscode/.dotnet/sdk/7.0.400/

Host:
  Version:      7.0.10
  Architecture: arm64
  Commit:       a6dbb800a4

.NET SDKs installed:
  7.0.400 [/home/vscode/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.21 [/home/vscode/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.10 [/home/vscode/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.21 [/home/vscode/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.10 [/home/vscode/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
scott-brady commented 1 year ago

This is possibly caused by a race condition where the Gauge.Dotnet.dll child process exists before the Kestrel host is started and ready to accept requests from the gauge parent process.

I noticed IGaugeCommand.Execute() returns Task<bool>, but in Program.Main() the call to command.Execute() is not awaited. I believe this might be causing the issue because the Main() method is sometimes exiting (and causing the program to exit) before the call to the asynchronous command.Execute() is complete.

This might be able to be resolved by simply adding an await to command.Execute().

scott-brady commented 1 year ago

Raised PR #197 with fix.

chadlwilson commented 1 month ago

Specific issue was resolved in #197 according to OP.