lark icon indicating copy to clipboard operation
lark copied to clipboard

Bot context is not safe for concurrent usage

Open jmasters-git opened this issue 1 year ago • 2 comments

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.

jmasters-git avatar Aug 12 '24 07:08 jmasters-git