Git Product home page Git Product logo

Comments (2)

TheAngryByrd avatar TheAngryByrd commented on May 14, 2024

I will look into this after I get the applicative work done.

from fstoolkit.errorhandling.

TheAngryByrd avatar TheAngryByrd commented on May 14, 2024

Chet and I did a livestream of this: https://www.twitch.tv/videos/625998302

Here are some of the initial results:


The result CE's original stack trace.

System.Exception: I'm a failure
   at ResultCETests.failureFunc[a]() in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 282
   at [email protected](Int32 _arg2) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 288
   at FsToolkit.ErrorHandling.ResultCE.ResultBuilder.Bind[T,TError,U](FSharpResult`2 result, FSharpFunc`2 binder) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/ResultCE.fs:line 21
   at [email protected](Int32 _arg1) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 287
   at FsToolkit.ErrorHandling.ResultCE.ResultBuilder.Bind[T,TError,U](FSharpResult`2 result, FSharpFunc`2 binder) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/ResultCE.fs:line 21
   at [email protected](Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 286
   at FsToolkit.ErrorHandling.ResultCE.ResultBuilder.Run[T,TError](FSharpFunc`2 generator) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/ResultCE.fs:line 31
   at ResultCETests.iDoCalls[a]() in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 285
   at ResultCETests.ResultCE stack [email protected](Unit unitVar0) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 295
   at [email protected](Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1666
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

As you can see we're spending a lot of time in the CE builder itself. With some inlining we've gotten to this stack trace:

System.Exception: I'm a failure
   at ResultCETests.failureFunc[a]() in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 282
   at [email protected](Int32 _arg2) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 288
   at [email protected](Int32 _arg1) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 287
   at [email protected](Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 286
   at ResultCETests.iDoCalls[a]() in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 285
   at ResultCETests.ResultCE stack [email protected](Unit unitVar0) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/ResultCE.fs:line 295
   at [email protected](Unit unitVar)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398

Which shows a vast improvement to clarify of where the error is coming from and removing the needless stackframes.


AsyncResult original stacktrace:

System.Exception: I'm a failure
   at [email protected](Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 422
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/Async.fs:line 8
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/Async.fs:line 8
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs:line 29
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs:line 46
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs:line 29
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs:line 46
   at AsyncResultCETests.AsyncResultCE stack [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 435
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1666
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

AsyncResult improved stacktrace:

System.Exception: I'm a failure
   at [email protected](Unit unitVar) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 422
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 398
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 428
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 428
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 427
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 427
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 426
   at [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 426
   at AsyncResultCETests.AsyncResultCE stack [email protected](AsyncActivation`1 ctxt) in /Users/jimmybyrd/Documents/GitHub/FsToolkit.ErrorHandling/tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs:line 435
   at <StartupCode$FSharp-Core>[email protected](AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1666
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

There's not a lot of gains in this scenario but it does make the error more clear in the sense we're not spending time in the CE builder, but it doesn't reduce the stackframes.


Given this I'm going to go ahead and inline all Bind/ReturnFrom/BindReturn/MergeSources methods and possibly any module level functions like AsyncResult.bind

from fstoolkit.errorhandling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.