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

Commit70723d3

Browse files
authored
fix(coderd): fix panics by always checking for non-nil request logger (#18228)
1 parentc95d972 commit70723d3

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

‎coderd/inboxnotifications.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ func (api *API) watchInboxNotifications(rw http.ResponseWriter, r *http.Request)
221221
deferencoder.Close(websocket.StatusNormalClosure)
222222

223223
// Log the request immediately instead of after it completes.
224-
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx,http.StatusAccepted)
224+
ifrl:=loggermw.RequestLoggerFromContext(ctx);rl!=nil {
225+
rl.WriteLog(ctx,http.StatusAccepted)
226+
}
225227

226228
for {
227229
select {

‎coderd/provisionerjobs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ func (f *logFollower) follow() {
557557
}
558558

559559
// Log the request immediately instead of after it completes.
560-
loggermw.RequestLoggerFromContext(f.ctx).WriteLog(f.ctx,http.StatusAccepted)
560+
ifrl:=loggermw.RequestLoggerFromContext(f.ctx);rl!=nil {
561+
rl.WriteLog(f.ctx,http.StatusAccepted)
562+
}
561563

562564
// no need to wait if the job is done
563565
iff.complete {

‎coderd/workspaceagents.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,9 @@ func (api *API) workspaceAgentLogs(rw http.ResponseWriter, r *http.Request) {
578578
defert.Stop()
579579

580580
// Log the request immediately instead of after it completes.
581-
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx,http.StatusAccepted)
581+
ifrl:=loggermw.RequestLoggerFromContext(ctx);rl!=nil {
582+
rl.WriteLog(ctx,http.StatusAccepted)
583+
}
582584

583585
gofunc() {
584586
deferfunc() {
@@ -1047,7 +1049,9 @@ func (api *API) derpMapUpdates(rw http.ResponseWriter, r *http.Request) {
10471049
deferencoder.Close(websocket.StatusGoingAway)
10481050

10491051
// Log the request immediately instead of after it completes.
1050-
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx,http.StatusAccepted)
1052+
ifrl:=loggermw.RequestLoggerFromContext(ctx);rl!=nil {
1053+
rl.WriteLog(ctx,http.StatusAccepted)
1054+
}
10511055

10521056
gofunc(ctx context.Context) {
10531057
// TODO(mafredri): Is this too frequent? Use separate ping disconnect timeout?
@@ -1501,7 +1505,9 @@ func (api *API) watchWorkspaceAgentMetadata(
15011505
defersendTicker.Stop()
15021506

15031507
// Log the request immediately instead of after it completes.
1504-
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx,http.StatusAccepted)
1508+
ifrl:=loggermw.RequestLoggerFromContext(ctx);rl!=nil {
1509+
rl.WriteLog(ctx,http.StatusAccepted)
1510+
}
15051511

15061512
// Send initial metadata.
15071513
sendMetadata()

‎enterprise/coderd/provisionerdaemons.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
384384
})
385385

386386
// Log the request immediately instead of after it completes.
387-
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx,http.StatusAccepted)
387+
ifrl:=loggermw.RequestLoggerFromContext(ctx);rl!=nil {
388+
rl.WriteLog(ctx,http.StatusAccepted)
389+
}
388390

389391
err=server.Serve(ctx,session)
390392
srvCancel()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp