Skip to content

Commit

Permalink
chore(api): add timeout for twitch user client
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Dec 3, 2023
1 parent 54d2756 commit 6ae1420
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/api/internal/impl_unprotected/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,17 @@ func (c *Stats) cacheStreamers() {
user := user
streamersFollowersWg.Go(
func() {
userTwitchClient, err := twitch.NewUserClient(user.ID, c.Config, c.Grpc.Tokens)
userTwitchClientCtx, userTwitchClientCtxCancel := context.WithTimeout(
context.Background(),
500*time.Millisecond,
)
defer userTwitchClientCtxCancel()
userTwitchClient, err := twitch.NewUserClientWithContext(
userTwitchClientCtx,
user.ID,
c.Config,
c.Grpc.Tokens,
)
if err != nil {
c.Logger.Error("cannot create twitch client", slog.Any("err", err))
return
Expand Down

0 comments on commit 6ae1420

Please sign in to comment.