Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2022-07-24 01:22:43 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2022-07-24 18:20:21 +0300
commit646685b42cd4cf14f6431633ef1b9f5c2d80ccfc (patch)
treea38d2ce91ba3e148df17479043c191c3e62033b0
parent78b28c3d54b449ab1439d7dfa8fb2f6a20dfbe13 (diff)
Handle Faraday::ServerError (for example 502) as HTTPFailure
closes #8380
-rw-r--r--Changelog.md1
-rw-r--r--lib/connection_tester.rb2
-rw-r--r--spec/lib/connection_tester_spec.rb5
3 files changed, 7 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index adc40086a..83d223c5f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -12,6 +12,7 @@
* Update the suggested Ruby version to 2.7. If you run into trouble during the update and you followed our installation guides, run `rvm install 2.7`. [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Upgrade to bundler 2 [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Stop checking `/.well-known/host-meta`, check for `/.well-known/nodeinfo` instead [#8377](https://github.com/diaspora/diaspora/pull/8377)
+* Handle NodeInfo timeouts gracefully [#8380](https://github.com/diaspora/diaspora/pull/8380)
## Bug fixes
* Fix that no mails were sent after photo export [#8365](https://github.com/diaspora/diaspora/pull/8365)
diff --git a/lib/connection_tester.rb b/lib/connection_tester.rb
index 810a3f2bd..d66f418f8 100644
--- a/lib/connection_tester.rb
+++ b/lib/connection_tester.rb
@@ -109,7 +109,7 @@ class ConnectionTester
raise NetFailure, e.message
rescue Faraday::SSLError => e
raise SSLFailure, e.message
- rescue ArgumentError, Faraday::ClientError => e
+ rescue ArgumentError, Faraday::ClientError, Faraday::ServerError => e
raise HTTPFailure, "#{e.class}: #{e.message}"
rescue StandardError => e
unexpected_error(e)
diff --git a/spec/lib/connection_tester_spec.rb b/spec/lib/connection_tester_spec.rb
index a0dce4d4f..d665dd717 100644
--- a/spec/lib/connection_tester_spec.rb
+++ b/spec/lib/connection_tester_spec.rb
@@ -94,6 +94,11 @@ describe ConnectionTester do
expect { tester.request }.to raise_error(ConnectionTester::HTTPFailure)
end
+ it "receives a 502 bad gateway" do
+ stub_request(:get, url).to_return(status: 502, body: "Bad Gateway!")
+ expect { tester.request }.to raise_error(ConnectionTester::HTTPFailure)
+ end
+
it "cannot connect" do
stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Error!"))
expect { tester.request }.to raise_error(ConnectionTester::NetFailure)