Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserFeedback with file attachment fails to send #1488

Closed
jschieck opened this issue Feb 16, 2022 · 3 comments · Fixed by #1489
Closed

UserFeedback with file attachment fails to send #1488

jschieck opened this issue Feb 16, 2022 · 3 comments · Fixed by #1489
Assignees
Labels
Bug Something isn't working

Comments

@jschieck
Copy link

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which version of the SDK?
0.10.0 (issue does not exist in 0.9.4)

Which version of Unity?
2020.3.18f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows?
Mac editor, did not bother testing others

Steps to Reproduce

  1. Send UserFeedback with a file attachment
  2. Stream DiposedException will occur when attempt to upload HttpContent
// omitted code
SentrySdk.WithScope(scope =>
{
    foreach (var attachmentPath in attachmentFilePaths)
    {
        var mimeType = attachmentPath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase) ? "application/zip" : "application/text";
        scope.AddAttachment(new Attachment(AttachmentType.Default, new FileAttachmentContent(attachmentPath), Path.GetFileName(attachmentPath), mimeType));
    }
    scope.SetFingerprint(Guid.NewGuid().ToString());
    var eventId = SentrySdk.CaptureMessage(message);
    SentrySdk.CaptureUserFeedback(new UserFeedback(eventId, null, null, message));
});

Expected Result

No error should occur and User Feedback is uploaded correctly

Actual Result

Sentry: (Error) Failed to serialize Envelope into the network stream System.ObjectDisposedException: Cannot access a closed Stream.
  at System.IO.Stream.CopyToAsync (System.IO.Stream destination, System.Int32 bufferSize, System.Threading.CancellationToken cancellationToken) [0x00042] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at PolyfillExtensions.CopyToAsync (System.IO.Stream stream, System.IO.Stream destination, System.Threading.CancellationToken cancellationToken) [0x00000] in <78b315d5ba0b4961ac680d18161ef295>:0 
  at Sentry.Protocol.Envelopes.StreamSerializable+<SerializeAsync>d__4.MoveNext () [0x00017] in <78b315d5ba0b4961ac680d18161ef295>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at Sentry.Protocol.Envelopes.EnvelopeItem+<SerializeAsync>d__21.MoveNext () [0x001a1] in <78b315d5ba0b4961ac680d18161ef295>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at Sentry.Protocol.Envelopes.Envelope+<SerializeAsync>d__10.MoveNext () [0x001a6] in <78b315d5ba0b4961ac680d18161ef295>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at Sentry.Internal.Http.EnvelopeHttpContent+<SerializeToStreamAsync>d__3.MoveNext () [0x00089] in <78b315d5ba0b4961ac680d18161ef295>:0 
UnityEngine.Debug:LogError (object)
Sentry.Unity.UnityLogger:Log (Sentry.SentryLevel,string,System.Exception,object[]) (at /Users/runner/work/sentry-unity/sentry-unity/src/Sentry.Unity/UnityLogger.cs:47)
Sentry.Extensibility.DiagnosticLoggerExtensions:LogIfEnabled (Sentry.Extensibility.IDiagnosticLogger,Sentry.SentryLevel,System.Exception,string)
Sentry.Extensibility.DiagnosticLoggerExtensions:LogError (Sentry.Extensibility.IDiagnosticLogger,string,System.Exception)
Sentry.Internal.Http.EnvelopeHttpContent/<SerializeToStreamAsync>d__3:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<Sentry.Internal.Http.EnvelopeHttpContent/<SerializeToStreamAsync>d__3> (Sentry.Internal.Http.EnvelopeHttpContent/<SerializeToStreamAsync>d__3&)
Sentry.Internal.Http.EnvelopeHttpContent:SerializeToStreamAsync (System.IO.Stream,System.Net.TransportContext)
System.Net.Http.DelegatingHandler:SendAsync (System.Net.Http.HttpRequestMessage,System.Threading.CancellationToken)
Sentry.Internal.Http.RetryAfterHandler:<>n__0 (System.Net.Http.HttpRequestMessage,System.Threading.CancellationToken)
Sentry.Internal.Http.RetryAfterHandler/<SendAsync>d__7:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<System.Net.Http.HttpResponseMessage>:Start<Sentry.Internal.Http.RetryAfterHandler/<SendAsync>d__7> (Sentry.Internal.Http.RetryAfterHandler/<SendAsync>d__7&)
Sentry.Internal.Http.RetryAfterHandler:SendAsync (System.Net.Http.HttpRequestMessage,System.Threading.CancellationToken)
System.Net.Http.HttpClient:SendAsync (System.Net.Http.HttpRequestMessage,System.Threading.CancellationToken)
Sentry.Internal.Http.HttpTransport/<SendEnvelopeAsync>d__13:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<Sentry.Internal.Http.HttpTransport/<SendEnvelopeAsync>d__13> (Sentry.Internal.Http.HttpTransport/<SendEnvelopeAsync>d__13&)
Sentry.Internal.Http.HttpTransport:SendEnvelopeAsync (Sentry.Protocol.Envelopes.Envelope,System.Threading.CancellationToken)
Sentry.Internal.Http.CachingTransport/<InnerProcessCacheAsync>d__15:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Sentry.Protocol.Envelopes.Envelope>:SetResult (Sentry.Protocol.Envelopes.Envelope)
Sentry.Internal.Http.CachingTransport/<ReadEnvelope>d__17:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Sentry.Protocol.Envelopes.Envelope>:SetResult (Sentry.Protocol.Envelopes.Envelope)
Sentry.Protocol.Envelopes.Envelope/<DeserializeAsync>d__20:MoveNext ()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Sentry.Protocol.Envelopes.EnvelopeItem>:SetResult (Sentry.Protocol.Envelopes.EnvelopeItem)

Any logs or screenshots

@bitsandfoxes
Copy link
Contributor

Hey @jschieck. Thanks for raising this and sorry to see you run into it. I can repro the issue locally and we'll take a look.

@bitsandfoxes bitsandfoxes added Bug Something isn't working Effort: Medium labels Feb 16, 2022
@SimonCropp SimonCropp transferred this issue from getsentry/sentry-unity Feb 17, 2022
@SimonCropp SimonCropp self-assigned this Feb 17, 2022
@SimonCropp
Copy link
Contributor

caused by https://github.com/getsentry/sentry-dotnet/pull/1476/files which changed the scoping of the stream.

@bruno-garcia
Copy link
Member

There's a new release of the Unity SDK with this fix:
https://github.com/getsentry/sentry-unity/releases/tag/0.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants