Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e6899f

Browse files
committed
fix: add better context and timeout for db related queries
1 parent779260e commit1e6899f

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 {returnoptions.AccessURL.String() },
13111311
"current_year":func()string {returnstrconv.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+
defercancel()
1315+
1316+
logoURL,err:=options.Database.GetLogoURL(ctx)
13141317
iferr!=nil {
13151318
iferrors.Is(err,sql.ErrNoRows) {
13161319
returnnotifications.NotificationsDefaultLogoURL
@@ -1322,7 +1325,10 @@ func templateHelpers(options *coderd.Options) map[string]any {
13221325
returnlogoURL
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+
defercancel()
1330+
1331+
appName,err:=options.Database.GetApplicationName(ctx)
13261332
iferr!=nil {
13271333
iferrors.Is(err,sql.ErrNoRows) {
13281334
returnnotifications.NotificationsDefaultAppName

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp