getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
218 stars 52 forks source link

Console shows error when launching game in the editor #1841

Closed bruno-garcia closed 1 month ago

bruno-garcia commented 1 month ago

I'm updating Sentry in sentry-defenses from 1.1.0 to 2.2.0. When I launch it in the Editor, I get an error about persisting the session id.

Unity version 2022.3.46 (bump'ed in this PR)

Sentry: (Error) Failed to persist session on the file system. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Stream has been closed'.
  at System.IO.FileStream.Flush () [0x0000d] in <606c2e0a56af495988c860a4ac613e74>:0 
  at System.Text.Json.Utf8JsonWriter.Flush () [0x00094] in <106b5ea9b1fa4ad5922e9fb9e8765bf0>:0 
  at System.Text.Json.Utf8JsonWriter.Dispose () [0x00011] in <106b5ea9b1fa4ad5922e9fb9e8765bf0>:0 
  at Sentry.GlobalSessionManager.PersistSession (Sentry.SessionUpdate update, System.Nullable`1[T] pauseTimestamp) [0x0011b] in /sentry-unity/src/sentry-dotnet/src/Sentry/GlobalSessionManager.cs:91 
UnityEngine.Logger:Log (UnityEngine.LogType,string,object)
Sentry.Unity.UnityLogger:Log (Sentry.SentryLevel,string,System.Exception,object[]) (at /sentry-unity/src/Sentry.Unity/UnityLogger.cs:33)
Sentry.Extensibility.DiagnosticLoggerExtensions:LogIfEnabled (Sentry.Extensibility.IDiagnosticLogger,Sentry.SentryLevel,System.Exception,string) (at /sentry-unity/src/sentry-dotnet/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs:478)
Sentry.Extensibility.DiagnosticLoggerExtensions:LogError (Sentry.SentryOptions,System.Exception,string) (at /sentry-unity/src/sentry-dotnet/src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs:288)
Sentry.GlobalSessionManager:PersistSession (Sentry.SessionUpdate,System.Nullable`1<System.DateTimeOffset>) (at /sentry-unity/src/sentry-dotnet/src/Sentry/GlobalSessionManager.cs:95)
Sentry.GlobalSessionManager:StartSession () (at /sentry-unity/src/sentry-dotnet/src/Sentry/GlobalSessionManager.cs:242)
Sentry.Internal.Hub:StartSession () (at /sentry-unity/src/sentry-dotnet/src/Sentry/Internal/Hub.cs:286)
Sentry.Integrations.AutoSessionTrackingIntegration:Register (Sentry.IHub,Sentry.SentryOptions) (at /sentry-unity/src/sentry-dotnet/src/Sentry/Integrations/AutoSessionTrackingIntegration.cs:9)
Sentry.Internal.Hub:.ctor (Sentry.SentryOptions,Sentry.ISentryClient,Sentry.ISessionManager,Sentry.Infrastructure.ISystemClock,Sentry.Internal.IInternalScopeManager,Sentry.Internal.RandomValuesFactory) (at /sentry-unity/src/sentry-dotnet/src/Sentry/Internal/Hub.cs:79)
Sentry.SentrySdk:InitHub (Sentry.SentryOptions) (at /sentry-unity/src/sentry-dotnet/src/Sentry/SentrySdk.cs:80)
Sentry.SentrySdk:Init (Sentry.SentryOptions) (at /sentry-unity/src/sentry-dotnet/src/Sentry/SentrySdk.cs:204)
Sentry.Unity.SentryUnitySdk:Init (Sentry.Unity.SentryUnityOptions) (at /sentry-unity/src/Sentry.Unity/SentryUnitySDK.cs:50)
Sentry.Unity.SentryUnity:Init (Sentry.Unity.SentryUnityOptions) (at /sentry-unity/src/Sentry.Unity/SentryUnity.cs:38)
Sentry.Unity.SentryInitialization:Init () (at ./Library/PackageCache/io.sentry.unity@45693349cd/Runtime/SentryInitialization.cs:88)

Image

lcnvdl commented 1 month ago

I'm having the same issue. My Unity version is 2021.3.34f1

bruno-garcia commented 1 month ago

We figured out what's wrong and fix is coming out on 2.2.1

Closing this as a dupe of: