-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
What
Add deterministic reasons in the code why contexts are getting canceled.
Why
It's hard to determine why a Context is canceled, causing:
- Hiding race conditions
- Makes it difficult to understand system behavior
- Makes it difficult to fix bugs
Some examples where it is reported that the reason for canceling a Context is unclear:
- Data race during panic and running code on event loop #5534
- Context canceling causing browser integration tests to fail very often #5504
- Improve browser close detection constant timeout #4314
- Error when initializing networking: network.EnableParams #4417
How
- Use
Context.WithCancelCauseand friends. - The error passed to these contexts should be chained with
Errorfso that we can see the chain of cancellation reasons.