Skip to content

Envelopes with oversized attachments getting stuck in __processing (Possible regression) #3804

Closed

Description

@jamescrosswell

Originally posted by @jamescrosswell in #3792

macOS

On macOS, the following code results in a java.net.SocketException: Socket closed exception when processing the envelope:

.UseSentry(options =>
{
                // All the standard options
                const int mb = 1024 * 1024;
                options.MaxAttachmentSize = 80 * mb;
                options.SetBeforeSend((e, h) =>
                {
                    var random = new Random();
                    var byteArray = new byte[20 * mb];
                    random.NextBytes(byteArray);

                    h.AddAttachment(byteArray, $"twentymb.bin");

                    return e;
                });
}

Additionally, the envelope getting stuck in the __processing directory and preventing other envelopes from being sent. I think that is a problem in the .NET SDK and possibly a regression of:

Activity

  1. jamescrosswell commented on Jan 28, 2025

    @jamescrosswell
    CollaboratorAuthor

    When attempting to send these envelopes, because the server is simply disconnecting, the client SDK is executing this logic (try again when the network is "back online"):

    catch (Exception ex) when (IsNetworkError(ex))
    {
    if (_options.NetworkStatusListener is PollingNetworkStatusListener pollingListener)
    {
    pollingListener.Online = false;
    }
    _options.LogError(ex, "Failed to send cached envelope: {0}, retrying after a delay.", file);
    // Let the worker catch, log, wait a bit and retry.
    throw;
    }

    Instead of this logic (fail and log):

    catch (Exception ex)
    {
    _options.ClientReportRecorder.RecordDiscardedEvents(DiscardReason.CacheOverflow, envelope);
    LogFailureWithDiscard(file, ex);
    }

    The IsNetworkError method is overly simplistic:

    private static bool IsNetworkError(Exception exception) =>
    exception switch
    {
    HttpRequestException or WebException or IOException or SocketException => true,
    _ => false
    };

    In the case of Broken Pipe or Connection Reset by Peer socket exceptions, we should probably assume the connection was reset intentionally by the remote host and fail/discard these envelopes.

  2. ghost added
    BugSomething isn't working
    on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething isn't working

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions