From 155bb0f599c0e7c0d89d83644051a599826f6b7c Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Fri, 3 Feb 2023 11:41:01 +0100 Subject: [PATCH 1/4] fix: Don't block on sending envelopes --- sentry/src/transports/tokio_thread.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sentry/src/transports/tokio_thread.rs b/sentry/src/transports/tokio_thread.rs index 4a99a7a3..17ab9d27 100644 --- a/sentry/src/transports/tokio_thread.rs +++ b/sentry/src/transports/tokio_thread.rs @@ -85,7 +85,12 @@ impl TransportThread { } pub fn send(&self, envelope: Envelope) { - let _ = self.sender.send(Task::SendEnvelope(envelope)); + // Using send here would mean that when the channel fills up for whatever + // reason, trying to send an envelope would block everything. We'd rather + // drop the envelope in that case. + if let Err(e) = self.sender.try_send(Task::SendEnvelope(envelope)) { + eprintln!("envelope dropped: {e}"); + } } pub fn flush(&self, timeout: Duration) -> bool { From c3181ec057bc30a46189c51995b0b08504f288b5 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Fri, 3 Feb 2023 11:45:04 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 630235f9..45e58e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Envelopes will be discarded rather than blocking if the transport channel fills up. ([#546](https://github.com/getsentry/sentry-rust/pull/546)) + ## 0.29.2 ### Various fixes & improvements From c221dc26cf3237a9d4285194dba8afb6ce3a6885 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Fri, 3 Feb 2023 14:13:51 +0100 Subject: [PATCH 3/4] print error with sentry_debug --- sentry/src/transports/tokio_thread.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry/src/transports/tokio_thread.rs b/sentry/src/transports/tokio_thread.rs index 17ab9d27..5ea1ae5e 100644 --- a/sentry/src/transports/tokio_thread.rs +++ b/sentry/src/transports/tokio_thread.rs @@ -89,7 +89,7 @@ impl TransportThread { // reason, trying to send an envelope would block everything. We'd rather // drop the envelope in that case. if let Err(e) = self.sender.try_send(Task::SendEnvelope(envelope)) { - eprintln!("envelope dropped: {e}"); + sentry_debug!("envelope dropped: {e}"); } } From 110a37e70f9966c55ae8fd3523aaae3e9e579e53 Mon Sep 17 00:00:00 2001 From: Sebastian Zivota Date: Fri, 3 Feb 2023 14:18:08 +0100 Subject: [PATCH 4/4] Changelog formatting --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e58e77..9311f0bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -### Fixes +**Fixes**: - Envelopes will be discarded rather than blocking if the transport channel fills up. ([#546](https://github.com/getsentry/sentry-rust/pull/546))