Skip to content

Commit

Permalink
Adding Wait on 202 of v3 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek committed Nov 5, 2024
1 parent 26fe26a commit 6b197a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/Agent/Agents/HttpAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ public async Task<CandidArg> CallAsync(
this.v3CallSupported = false;
return await this.CallAsynchronousAndWaitAsync(canisterId, method, arg, effectiveCanisterId, cancellationToken);
}
// TODO
// if (httpResponse.StatusCode == System.Net.HttpStatusCode.Accepted){
// // If request takes too long, then it will return 202 Accepted
// // and polling is required
// return await this.WaitAsync();
// }
if (httpResponse.StatusCode == System.Net.HttpStatusCode.Accepted)
{
// If request takes too long, then it will return 202 Accepted and polling is required
return await this.WaitForRequestAsync(canisterId, requestId, cancellationToken);
}
await httpResponse.ThrowIfErrorAsync();

byte[] cborBytes = await httpResponse.GetContentAsync();
Expand Down
2 changes: 1 addition & 1 deletion src/Agent/Agents/IAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static async Task<CandidArg> CallAsynchronousAndWaitAsync(
Principal? effectiveCanisterId = null,
CancellationToken? cancellationToken = null)
{
RequestId id = await agent.CallAsync(canisterId, method, arg, effectiveCanisterId);
RequestId id = await agent.CallAsynchronousAsync(canisterId, method, arg, effectiveCanisterId);
return await agent.WaitForRequestAsync(canisterId, id, cancellationToken);
}

Expand Down

0 comments on commit 6b197a2

Please sign in to comment.