diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41b2f87b54..84187b554c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -298,10 +298,19 @@ jobs: # TODO: Once test/Npgsql.Specification.Tests work, switch to just testing on the solution - name: Test run: | - dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.Tests --logger "GitHubActions;report-warnings=false" --blame-hang-timeout 30s + dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.Tests --logger "GitHubActions;report-warnings=false" --blame-crash --blame-hang-timeout 30s dotnet test -c ${{ matrix.config }} -f ${{ matrix.test_tfm }} test/Npgsql.DependencyInjection.Tests --logger "GitHubActions;report-warnings=false" shell: bash + - name: Upload Test Hang Dumps + uses: actions/upload-artifact@v6 + if: failure() + with: + name: test-hang-dumps + path: | + **/*.dmp + **/Sequence*.xml + - name: Test Plugins if: "!startsWith(matrix.os, 'macos')" run: | diff --git a/src/Npgsql/Internal/NpgsqlConnector.cs b/src/Npgsql/Internal/NpgsqlConnector.cs index 6bca520d43..4c18372699 100644 --- a/src/Npgsql/Internal/NpgsqlConnector.cs +++ b/src/Npgsql/Internal/NpgsqlConnector.cs @@ -1339,7 +1339,7 @@ async Task ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationTok } else { - IPAddress[] ipAddresses; + IPAddress[] ipAddresses = []; try { using var combinedCts = timeout.IsSet ? CancellationTokenSource.CreateLinkedTokenSource(cancellationToken) : null; @@ -1352,7 +1352,8 @@ async Task ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationTok catch (OperationCanceledException) { cancellationToken.ThrowIfCancellationRequested(); - throw new TimeoutException(); + Debug.Assert(timeout.HasExpired); + ThrowHelper.ThrowNpgsqlExceptionWithInnerTimeoutException("The operation has timed out"); } } catch (SocketException ex)