From 7e0ca278362f5984430c31b0bc3116ea0e503023 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Fri, 3 Apr 2026 16:23:37 -0400 Subject: [PATCH] backport: put a promise in that panic --- sgx-bwmsgsv2.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 83d0181a459cc11c4f87c5781e027be1962479d6..d321b38f06b989faffa2ed138cf486d322c920dd 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -162,15 +162,17 @@ MMS_MIME_TYPES = [ MAX_MEDIA_SIZE = 1000000 def panic(e) - if e.is_a?(Exception) - Sentry.capture_exception(e, hint: { background: false }) - else - Sentry.capture_message(e.to_s, hint: { background: false }) - end - LOG.fatal("Shutting down gateway", e) - SGXbwmsgsv2.shutdown - LOG.info "Gateway has terminated" - EM.stop + EMPromise.resolve(nil).then { + if e.is_a?(Exception) + Sentry.capture_exception(e, hint: { background: false }) + else + Sentry.capture_message(e.to_s, hint: { background: false }) + end + LOG.fatal("Shutting down gateway", e) + SGXbwmsgsv2.shutdown + LOG.info "Gateway has terminated" + EM.stop + } end EM.error_handler(&method(:panic))