Skip to content

Context cancelation cause detection #5535

@inancgumus

Description

@inancgumus

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:

How

  • Use Context.WithCancelCause and friends.
  • The error passed to these contexts should be chained with Errorf so that we can see the chain of cancellation reasons.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions