Skip to content

Sentry fails to initialize in Blazor with AoT enabled #3263

Closed

Description

@klemmchr

Package

Sentry

.NET Flavor

.NET

.NET Version

8.0.0

OS

Browser

SDK Version

4.2.1

Self-Hosted Sentry Version

No response

Steps to Reproduce

Repro: sentry-blazor-repro.zip

  1. Build included Dockerfile
  2. Start docker image and bind port 8080
  3. Open http://localhost:8080 and open console

Expected Result

Web app loads properly and starts up. This works fine when using Sentry.Extensions.Logging 3.41.4 but breaks after doing the major upgrade to 4.

Actual Result

Web app fails to load

Error: AggregateException_ctor_DefaultMessage (sentry-native)
    at Jn (dotnet.runtime.8.0.3.b85ar3xvhg.js:3:31614)
    at xl (dotnet.runtime.8.0.3.b85ar3xvhg.js:3:182162)
    at dotnet.native.wasm:0xb7f885
    at dotnet.native.wasm:0xb8125f
    at dotnet.native.wasm:0xb86cc5
    at dotnet.native.wasm:0xe6866
    at dotnet.native.wasm:0x130d162
    at dotnet.native.wasm:0x132a1bb
    at dotnet.native.wasm:0x1309ad4
    at dotnet.native.wasm:0x12fced1

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 6, 2024
  2. changed the title [-]Sentry fails on Blazor with AoT enabled[/-] [+]Sentry fails to initialize in Blazor with AoT enabled[/+] on Apr 6, 2024
  3. bitsandfoxes commented on Apr 8, 2024

    @bitsandfoxes
    Contributor

    Thanks, @klemmchr for the detailed issue and the repro in particular!

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 8, 2024
  5. jamescrosswell commented on Apr 16, 2024

    @jamescrosswell
    Collaborator

    Confirming that I can reproduce this when building and running in docker.

    Debug: Logging enabled with ConsoleDiagnosticLogger and min level: Debug
    dotnet.native.8.0.4.xlcgqfj2gk.js:8 Warning: Sentry option 'Debug' is set to true while Environment is production. Be aware this can cause performance degradation and is not advised. See https://docs.sentry.io/platforms/dotnet/configuration/diagnostic-logger for more information
    dotnet.native.8.0.4.xlcgqfj2gk.js:8   Error: Failure getting precise App startup time.
    dotnet.native.8.0.4.xlcgqfj2gk.js:8 System.PlatformNotSupportedException: Process_PlatformNotSupported
    dotnet.native.8.0.4.xlcgqfj2gk.js:8    at Sentry.Internal.ProcessInfo.GetStartupTime()
    dotnet.native.8.0.4.xlcgqfj2gk.js:8    at Sentry.Internal.ProcessInfo.<>c__DisplayClass15_1.<.ctor>b__0()
    blazor.webassembly.js:1 Error: AggregateException_ctor_DefaultMessage (sentry-native)
        at Jn (dotnet.runtime.8.0.4.17vw47cxz6.js:3:31614)
        at xl (dotnet.runtime.8.0.4.17vw47cxz6.js:3:182261)
        at dotnet.native.wasm:0xb7f885
        at dotnet.native.wasm:0xb8125f
        at dotnet.native.wasm:0xb86cc5
        at dotnet.native.wasm:0xe6866
        at dotnet.native.wasm:0x130d162
        at dotnet.native.wasm:0x132a1bb
        at dotnet.native.wasm:0x1309ad4
        at dotnet.native.wasm:0x12fced1
    

    If Sentry is not initialized when running in Docker, everything works as expected.

    Also if AOT is disabled (setting <RunAOTCompilation>false</RunAOTCompilation> in the csproj file) then everything works as expected.

    Given that it only occurs when running AOT compiled code in Docker, it's relatively difficult to debug.

    It looks like we're getting a PlatformNotSupportedException from somewhere in the ProcessInfo constructor...

  6. jamescrosswell commented on Apr 16, 2024

    @jamescrosswell
    Collaborator

    OK so it might be this:

    using var proc = Process.GetCurrentProcess();

    Apparently that method can throw a PlatformNotSupportedException:

    The operating system platform does not support this operation on remote computers.

    And we are calling that in the constructor:

    var preciseStartupTimeFunc = findPreciseStartupTime ?? GetStartupTime;

  7. jamescrosswell commented on Apr 16, 2024

    @jamescrosswell
    Collaborator

    Dang, dead end... all of that is just this (which is wrapped in a try catch and logging the exception - it won't be what's crashing the process then) 😞 :

    try
    {
    StartupTime = preciseStartupTimeFunc();
    }
    catch (Exception e)
    {
    options.LogError(e, "Failure getting precise App startup time.");
    //Ignore any exception and stay with the less-precise DateTime.UtcNow value.
    }

  8. bitsandfoxes commented on Apr 22, 2024

    @bitsandfoxes
    Contributor

    After our sync: We think we should disable sentry-native when targeting Blazor.

  9. klemmchr commented on Apr 22, 2024

    @klemmchr
    Author

    Is there any ETA on when this fix can be expected? I'm desperate to update the SDK to v4.

  10. 2 remaining items

  11. bitsandfoxes commented on Apr 22, 2024

    @bitsandfoxes
    Contributor

    Doubleconfirming: I can reproduce this locally with our own Blazor.Wasm sample outside of docker. A fix should follow shortly.

  12. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 22, 2024
  13. klemmchr commented on May 9, 2024

    @klemmchr
    Author

    @bitsandfoxes may I ask for an update? It has been over a month now where this critical bug has not been fixed. There is a bit of irony to it, given that Sentry proudly announced AoT support in v4 for non-console apps (which is not working) while having working AoT in v3 without any trouble.

    It's a bit underwhelming to see no real progress on this issue even though I provided a one-click repro in my initial post giving you all the information you could desire.

  14. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 9, 2024
  15. bitsandfoxes commented on May 10, 2024

    @bitsandfoxes
    Contributor

    Hey @klemmchr, sorry about that. The issue fell through the cracks. We'll pick it back up and you can expect a fix early next week.

  16. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 10, 2024
  17. klemmchr commented on May 13, 2024

    @klemmchr
    Author

    @bitsandfoxes great to see that this got fixed. Is this going to be released as a patch or do we need to wait for the next minor release? And if so, is there any timeline/release cycle for this?

  18. bitsandfoxes commented on May 14, 2024

    @bitsandfoxes
    Contributor

    Hey @klemmchr, it's part of 4.6.1 that's coming out right now. (or whenever CI is done doing its thing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions