Skip to content

Commit a32d0ef

Browse files
committed
fix: add better context and timeout for db related queries
1 parent bbcca34 commit a32d0ef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cli/server.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,10 @@ func templateHelpers(options *coderd.Options) map[string]any {
13101310
"base_url": func() string { return options.AccessURL.String() },
13111311
"current_year": func() string { return strconv.Itoa(time.Now().Year()) },
13121312
"logo_url": func() string {
1313-
logoURL, err := options.Database.GetLogoURL(context.Background())
1313+
ctx, cancel := context.WithTimeout(context.Background(), 1 * time.Second)
1314+
defer cancel()
1315+
1316+
logoURL, err := options.Database.GetLogoURL(ctx)
13141317
if err != nil {
13151318
if errors.Is(err, sql.ErrNoRows) {
13161319
return notifications.NotificationsDefaultLogoURL
@@ -1322,7 +1325,10 @@ func templateHelpers(options *coderd.Options) map[string]any {
13221325
return logoURL
13231326
},
13241327
"app_name": func() string {
1325-
appName, err := options.Database.GetApplicationName(context.Background())
1328+
ctx, cancel := context.WithTimeout(context.Background(), 1 * time.Second)
1329+
defer cancel()
1330+
1331+
appName, err := options.Database.GetApplicationName(ctx)
13261332
if err != nil {
13271333
if errors.Is(err, sql.ErrNoRows) {
13281334
return notifications.NotificationsDefaultAppName

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy