Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.

Large response outofmem fix #564

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions ClickHouse.Client/ADO/ClickHouseConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,21 @@ internal static async Task<HttpResponseMessage> HandleError(HttpResponseMessage
activity.SetSuccess();
return response;
}
var error = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var ex = ClickHouseServerException.FromServerResponse(error, query);
activity.SetException(ex);
throw ex;
string description = response?.ReasonPhrase ?? string.Empty;
activity?.SetStatus(ActivityStatusCode.Error, description);
var ex = new Exception($"Error '{response?.StatusCode}' reading server response: {description}");
try
{
await response.Content.LoadIntoBufferAsync(4096);
var stream = (MemoryStream)await response.Content.ReadAsStreamAsync();
Copy link
Owner

@DarkWanderer DarkWanderer Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the cast to MemoryStream for?

var error = new StreamReader(stream).ReadToEnd();
ex = ClickHouseServerException.FromServerResponse(error, query);
activity?.SetException(ex);
}
finally
{
throw ex;
}
}

public override void ChangeDatabase(string databaseName) => database = databaseName;
Expand Down
Loading