diff --git a/server/channels/app/integration_action.go b/server/channels/app/integration_action.go index 15847dee26..f840cd9824 100644 --- a/server/channels/app/integration_action.go +++ b/server/channels/app/integration_action.go @@ -232,7 +232,10 @@ func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, se if err != nil { 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 { return "", appErr } @@ -307,10 +310,7 @@ func (a *App) DoActionRequest(c request.CTX, rawURL string, body []byte) (*http. return a.DoLocalRequest(c, rawURLPath, body) } - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(*a.Config().ServiceSettings.OutgoingIntegrationRequestsTimeout)*time.Second) - defer cancel() - - req, err := http.NewRequestWithContext(ctx, "POST", rawURL, bytes.NewReader(body)) + req, err := http.NewRequestWithContext(c.Context(), "POST", rawURL, bytes.NewReader(body)) if err != nil { if errors.Is(err, context.DeadlineExceeded) { 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) } - 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 { return nil, appErr }