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

Bot context is not safe for concurrent usage #74

Open
jmasters-git opened this issue Aug 12, 2024 · 2 comments
Open

Bot context is not safe for concurrent usage #74

jmasters-git opened this issue Aug 12, 2024 · 2 comments

Comments

@jmasters-git
Copy link

At the moment the only way to pass a context through when making requests is to use WithContext(ctx) from logger.go:76, but this sets the context globally on bot.ctx (defined here). This is an issue for us because this means we cannot pass in a context for each individual request, since bot.ctx will be shared among all concurrent requests.

We want to use the context to provide request specific information (such as log ids and tracing spans) to the logger and potentially update the current implementation to use http.NewRequestWithContext instead of http.NewRequest (here) to allow cancellation/timeout of requests.

Instead of having a single context associated with a Bot instance, we would like to be able pass a context with each request.

@crispgm
Copy link
Contributor

crispgm commented Aug 13, 2024

Thanks for reporting. This is a known issue because of early design. It will be a breaking change if we introduce context. Maybe I should launch V4 for support this.

@marsberrys
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants