[MM-57298] Fix context cancellation for integration requests (#26516)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4bbcfd74ad
Коммит
3efb25667d
@@ -232,7 +232,10 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", model.NewAppError("DoPostActionWithCookie", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
return "", model.NewAppError("DoPostActionWithCookie", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||||
}
|
}
|
||||||
resp, appErr := a.DoActionRequest(c, upstreamURL, requestJSON)
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(*a.Config().ServiceSettings.OutgoingIntegrationRequestsTimeout)*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
resp, appErr := a.DoActionRequest(c.WithContext(ctx), upstreamURL, requestJSON)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return "", appErr
|
return "", appErr
|
||||||
}
|
}
|
||||||
@@ -307,10 +310,7 @@ func (a *App) DoActionRequest(c request.CTX, rawURL string, body []byte) (*http.
|
|||||||
return a.DoLocalRequest(c, rawURLPath, body)
|
return a.DoLocalRequest(c, rawURLPath, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(*a.Config().ServiceSettings.OutgoingIntegrationRequestsTimeout)*time.Second)
|
req, err := http.NewRequestWithContext(c.Context(), "POST", rawURL, bytes.NewReader(body))
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", rawURL, bytes.NewReader(body))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
c.Logger().Info("Outgoing Integration Action request timed out. Consider increasing ServiceSettings.OutgoingIntegrationRequestsTimeout.")
|
c.Logger().Info("Outgoing Integration Action request timed out. Consider increasing ServiceSettings.OutgoingIntegrationRequestsTimeout.")
|
||||||
@@ -484,7 +484,9 @@ func (a *App) SubmitInteractiveDialog(c request.CTX, request model.SubmitDialogR
|
|||||||
return nil, model.NewAppError("SubmitInteractiveDialog", "app.submit_interactive_dialog.json_error", nil, "", http.StatusBadRequest).Wrap(err)
|
return nil, model.NewAppError("SubmitInteractiveDialog", "app.submit_interactive_dialog.json_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, appErr := a.DoActionRequest(c, url, b)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(*a.Config().ServiceSettings.OutgoingIntegrationRequestsTimeout)*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
resp, appErr := a.DoActionRequest(c.WithContext(ctx), url, b)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return nil, appErr
|
return nil, appErr
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user