Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Rescue from Errno::ECONNREFUSED.
Sebastian Palma1ce8962c5f62
diff --git a/api/app/services/spree/webhooks/endpoints/make_request.rb b/api/app/services/spree/webhooks/endpoints/make_request.rbindex 8fdb185c57..eb411cc5e8 100644--- a/api/app/services/spree/webhooks/endpoints/make_request.rb+++ b/api/app/services/spree/webhooks/endpoints/make_request.rb@@ -29,7 +29,7 @@ module Spreedef request_status_codehttp.request(request).code.to_i- rescue SocketError, Net::ReadTimeout+ rescue Errno::ECONNREFUSED, Net::ReadTimeout, SocketError0enddiff --git a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rbindex 6ab51b12ff..af9451a019 100644--- a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb@@ -709,7 +709,6 @@ describe 'API V2 Storefront Checkout Spec', type: :request do# complete the checkoutpatch '/api/v2/storefront/checkout/complete', headers: headersexpect(response.status).to eq(200)- order.reloadexpect(order.reload.completed_at).not_to be_nilexpect(order.state).to eq('complete')expect(order.payments.valid.first.payment_method).to eq(payment_method)diff --git a/api/spec/services/spree/webhooks/endpoints/make_request_spec.rb b/api/spec/services/spree/webhooks/endpoints/make_request_spec.rbindex dbcededc47..f02a4505bd 100644--- a/api/spec/services/spree/webhooks/endpoints/make_request_spec.rb+++ b/api/spec/services/spree/webhooks/endpoints/make_request_spec.rb@@ -89,22 +89,21 @@ describe Spree::Webhooks::Endpoints::MakeRequest doendend- context 'when the request raises a SocketError exception' do- before do- allow(Net::HTTP).to receive(:new).and_return(http_double)- allow(http_double).to receive(:request) { raise SocketError }- end-- it { expect(subject).to eq(true) }- end+ describe 'rescuing from known exceptions' do+ shared_examples 'rescues from' do |exception|+ before do+ allow(Net::HTTP).to receive(:new).and_return(http_double)+ allow(http_double).to receive(:request) { raise exception }+ end- context 'when the request raises a Net::ReadTimeout exception' do- before do- allow(Net::HTTP).to receive(:new).and_return(http_double)- allow(http_double).to receive(:request) { raise Net::ReadTimeout }+ it "rescues from #{exception} and returns it is a failed request" do+ expect(subject).to eq(true)+ endend- it { expect(subject).to eq(true) }+ include_examples 'rescues from', Errno::ECONNREFUSED+ include_examples 'rescues from', Net::ReadTimeout+ include_examples 'rescues from', SocketErrorendcontext 'when the request status code is not 2xx' do