ChilliCream / ChilliCream/graphql-platform
Inconsistent Cancellation Behavior in StrawberryShake client
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Product
Strawberry Shake
Version
15.1.11
Link to minimal reproduction
https://github.com/ben-hamida/StrawberryShake-Cancellation-Repro
Steps to reproduce
Run the tests in my repro. The first test shows how a request that is canceled early throws an IncalidOperationException. The seconds test shows when canceled late, an error result is returned instead.
What is expected?
Both cases should throw an InvalidOperationException.
What is actually happening?
When cancellation is signaled early an OperationCanceledException is thrown, while if it is signaled late an error is reported in the returned result type instead with the message "A task was canceled."
Relevant log output
Additional context
In StrawberryShake.Transport.Http.ResponseEnumerable, any OperationCanceledException that client.SendAsync might throw will propagated up, while if it's thrown by result.ReadAsResultStreamAsync or enumerator.MoveNextAsync it is caught and converted into a JsonDocument.
The most idiomatic behavior is to let it bubble up. When converted into a generic result type it becomes difficult to distinguish it from other errors. For example in an ASP Core application it's often desirable to let OperationCanceledException be handled by the framework without logging it as an error, while other errors we often want to catch early and log.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with StrawberryShake.Transport.Http.ResponseEnumerable and run the tests in the linked StrawberryShake-Cancellation-Repro. Compare cancellation during client.SendAsync with cancellation during result.ReadAsResultStreamAsync or enumerator.MoveNextAsync. Done means both cancellation paths consistently surface InvalidOperationException rather than returning an error result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, graphql
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100