Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#54293] Reenable HTTPX persistent connections.

Pavel Balashou341e557721fe
diff --git a/lib/open_project.rb b/lib/open_project.rb
index 4027bd1810a..9fd814bacee 100644
--- a/lib/open_project.rb
+++ b/lib/open_project.rb
@@ -47,20 +47,23 @@ module OpenProject
end
def self.httpx
- session = HTTPX
- .plugin(:oauth)
- .plugin(:basic_auth)
- .plugin(:webdav)
- .with(
- timeout: {
- connect_timeout: OpenProject::Configuration.httpx_connect_timeout,
- operation_timeout: OpenProject::Configuration.httpx_operation_timeout,
- request_timeout: OpenProject::Configuration.httpx_request_timeout,
- write_timeout: OpenProject::Configuration.httpx_write_timeout,
- read_timeout: OpenProject::Configuration.httpx_read_timeout,
- keep_alive_timeout: OpenProject::Configuration.httpx_keep_alive_timeout
- }
- )
- OpenProject::Appsignal.enabled? ? session.plugin(HttpxAppsignal) : session
+ Thread.current[:httpx_session] ||= begin
+ session = HTTPX
+ .plugin(:oauth)
+ .plugin(:persistent)
+ .plugin(:basic_auth)
+ .plugin(:webdav)
+ .with(
+ timeout: {
+ connect_timeout: OpenProject::Configuration.httpx_connect_timeout,
+ operation_timeout: OpenProject::Configuration.httpx_operation_timeout,
+ request_timeout: OpenProject::Configuration.httpx_request_timeout,
+ write_timeout: OpenProject::Configuration.httpx_write_timeout,
+ read_timeout: OpenProject::Configuration.httpx_read_timeout,
+ keep_alive_timeout: OpenProject::Configuration.httpx_keep_alive_timeout
+ }
+ )
+ OpenProject::Appsignal.enabled? ? session.plugin(HttpxAppsignal) : session
+ end
end
end
diff --git a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
index 0fdf14b64eb..b576fbf51f0 100644
--- a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
@@ -93,7 +93,8 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :
expect(subject.errors.to_hash)
.to eq({ password: ["could not be validated. Please check your storage connection and try again."] })
- expect(credentials_request).to have_been_made.once
+ # twice due to HTTPX retry plugin being enabled.
+ expect(credentials_request).to have_been_made.twice
end
end
diff --git a/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb b/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
index d4c141e4849..b157aea0fa0 100644
--- a/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
+++ b/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
@@ -192,7 +192,8 @@ RSpec.shared_examples_for "nextcloud storage contract", :storage_server_helpers,
it "retries failed request once" do
contract.validate
- expect(stub_server_capabilities).to have_been_made.once
+ # twice due to HTTPX retry plugin being enabled.
+ expect(stub_server_capabilities).to have_been_made.twice
end
end
@@ -203,8 +204,8 @@ RSpec.shared_examples_for "nextcloud storage contract", :storage_server_helpers,
it "retries failed request once" do
contract.validate
-
- expect(stub_config_check).to have_been_made.once
+ # twice due to HTTPX retry plugin being enabled.
+ expect(stub_config_check).to have_been_made.twice
end
end
end