mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
fix(coderd): fix panics by always checking for non-nil request logger (#18228)
This commit is contained in:
committed by
GitHub
parent
c95d972d4e
commit
70723d3b51
@ -221,7 +221,9 @@ func (api *API) watchInboxNotifications(rw http.ResponseWriter, r *http.Request)
|
|||||||
defer encoder.Close(websocket.StatusNormalClosure)
|
defer encoder.Close(websocket.StatusNormalClosure)
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(ctx); rl != nil {
|
||||||
|
rl.WriteLog(ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -557,7 +557,9 @@ func (f *logFollower) follow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(f.ctx).WriteLog(f.ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(f.ctx); rl != nil {
|
||||||
|
rl.WriteLog(f.ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
// no need to wait if the job is done
|
// no need to wait if the job is done
|
||||||
if f.complete {
|
if f.complete {
|
||||||
|
@ -578,7 +578,9 @@ func (api *API) workspaceAgentLogs(rw http.ResponseWriter, r *http.Request) {
|
|||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(ctx); rl != nil {
|
||||||
|
rl.WriteLog(ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -1047,7 +1049,9 @@ func (api *API) derpMapUpdates(rw http.ResponseWriter, r *http.Request) {
|
|||||||
defer encoder.Close(websocket.StatusGoingAway)
|
defer encoder.Close(websocket.StatusGoingAway)
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(ctx); rl != nil {
|
||||||
|
rl.WriteLog(ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
// TODO(mafredri): Is this too frequent? Use separate ping disconnect timeout?
|
// TODO(mafredri): Is this too frequent? Use separate ping disconnect timeout?
|
||||||
@ -1501,7 +1505,9 @@ func (api *API) watchWorkspaceAgentMetadata(
|
|||||||
defer sendTicker.Stop()
|
defer sendTicker.Stop()
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(ctx); rl != nil {
|
||||||
|
rl.WriteLog(ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
// Send initial metadata.
|
// Send initial metadata.
|
||||||
sendMetadata()
|
sendMetadata()
|
||||||
|
@ -384,7 +384,9 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Log the request immediately instead of after it completes.
|
// Log the request immediately instead of after it completes.
|
||||||
loggermw.RequestLoggerFromContext(ctx).WriteLog(ctx, http.StatusAccepted)
|
if rl := loggermw.RequestLoggerFromContext(ctx); rl != nil {
|
||||||
|
rl.WriteLog(ctx, http.StatusAccepted)
|
||||||
|
}
|
||||||
|
|
||||||
err = server.Serve(ctx, session)
|
err = server.Serve(ctx, session)
|
||||||
srvCancel()
|
srvCancel()
|
||||||
|
Reference in New Issue
Block a user