Remove request from requests dict after it was handled. This was a memory leak!
This commit is contained in:
parent
bc19a315da
commit
036897ecab
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hibas123/jrpcgen",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.20",
|
||||
"main": "lib/index.js",
|
||||
"license": "MIT",
|
||||
"packageManager": "yarn@3.1.1",
|
||||
|
@ -89,9 +89,19 @@ public class JRpcClient
|
||||
|
||||
var task = new TaskCompletionSource<JsonNode?>();
|
||||
this.Requests.Add(id, task);
|
||||
|
||||
try
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.Transport.Write(request.ToJsonString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
task.SetException(e);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.Timeout.HasValue)
|
||||
@ -102,7 +112,6 @@ public class JRpcClient
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Requests.Remove(id);
|
||||
throw new JRpcTimeoutException();
|
||||
}
|
||||
|
||||
@ -112,6 +121,11 @@ public class JRpcClient
|
||||
return await task.Task;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.Requests.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<TResult?> SendRequest<TResult>(string method, JsonArray param)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user