Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate Context from entry point to some functions to replace Background/TODO #21942

Open
sivchari opened this issue Feb 22, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@sivchari
Copy link
Contributor

sivchari commented Feb 22, 2025

Summary

Some function uses context.TODO or context.Background. So it's better to replace these to propagate context cancellation.

Motivation

Currenty, some function uses context.TODO or context.Background. As a result, some connection might be leaked, since the context isn't propagated.
In additional, context.TODO is ambiguous whether these codes are planed to replace right context or not.
Thus, I think it should replace context.Background instead of context.TODO.

Proposal

This migration might be done by 2 step.

  1. Add static analysis to forbid context.TODO and context.Background for finding thesd.
  2. propagate context from cmd/** to some functions
  3. Remain context.Background if it's impossible to replace

What do you think ?

@sivchari sivchari added the enhancement New feature or request label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant