Skip to content

Stack traces in the debug console do not show links for "_patch" files  #4727

Closed

Description

@lukehutch

Describe the bug

Sometimes when a Dart stacktrace is printed to the debug console, it is not parsed properly by VS Code. For example:

#0      ProfileInfoEndpoint._getAllUserInfo (package:click_server/src/endpoints/profile_endpoint.dart:29:7)
<asynchronous suspension>
#1      ProfileInfoEndpoint.updateProfile (package:click_server/src/endpoints/profile_endpoint.dart:49:9)
<asynchronous suspension>
#2      EndpointDispatch.handleUriCall (package:serverpod/src/server/endpoint_dispatch.dart:111:20)
<asynchronous suspension>
#3      Server._handleRequest (package:serverpod/src/server/server.dart:243:18)
<asynchronous suspension>

For this stacktrace, the filename and line numbers are not identified and linked in the debug console by VS Code. They are treated simply as text.

In this stacktrace, also from the debug console, some of the lines are correctly linked back to source (shown indented on a new line here, but shown as right-justified links in the debug console window in VS Code), and some are not:

E/flutter (10117): #0      List.[] (dart:core-patch/growable_array.dart:264:36)
E/flutter (10117): #1      _ProfilePhotoEditorListState._editCaption
        profile_photo_editor_list.dart:246
E/flutter (10117): #2      _ProfilePhotoEditorListState._addPhoto.<anonymous closure>.<anonymous closure>
        profile_photo_editor_list.dart:234
E/flutter (10117): #3      showPhotoCropper.<anonymous closure>.<anonymous closure>
        photo_cropper_widget.dart:40
E/flutter (10117): #4      new Future.delayed.<anonymous closure> (dart:async/future.dart:427:39)
E/flutter (10117): #5      Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (10117): #6      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (10117): #7      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (10117): #8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

Please complete the following information:

  • Operating System and version: Fedora 38
  • VS Code version: 1.81.1
  • Dart extension version: 3.72.1
  • Dart/Flutter SDK version: 3.10.0
  • Target device (if the issue relates to Flutter debugging):

Activity

  1. DanTup commented on Sep 6, 2023

    @DanTup
    Member

    @lukehutch can you easily include a screenshot of what you're seeing here? Are the lines that aren't linked correctly the ones that wrap and/or don't have full dart: or package: URIs?

  2. added
    awaiting infoRequires more information from the customer to progress
    on Sep 6, 2023
  3. github-actions commented on Sep 27, 2023

    @github-actions

    This issue has been marked stale because it is tagged awaiting-info for 20 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days.

  4. lukehutch commented on Sep 27, 2023

    @lukehutch
    Author

    I'll try to add a screenshot next time this happens.

  5. lukehutch commented on Oct 2, 2023

    @lukehutch
    Author

    OK, here is an example screenshot, where the filenames and line numbers are not parsed out and made linkable. They appear in the console as plaintext:

    image

  6. DanTup commented on Oct 2, 2023

    @DanTup
    Member

    @lukehutch was this exception something you caught and then printed, or was it unhandled/caught only by Flutter? Is it the entire call stack that's not linked, or only some lines?

    Thanks!

  7. lukehutch commented on Oct 2, 2023

    @lukehutch
    Author

    This was an uncaught exception. In this case, it was the entire stack trace that was unlinked. In other cases, it's just a few stack frames that are unlinked, sometimes in the middle of the stack trace.

  8. DanTup commented on Oct 2, 2023

    @DanTup
    Member

    Are you able to reproduce this in a small project you can share? There are some issues I know about in this area - one of them is fixed for the next SDKs but was Flutter-specific (#4571) and it's not clear if you hit this in Flutter, and the other only occurs when stack traces are printed (and not unhandled).

    If you can share a repo, I can check whether there's another issue or this is one of those (and whether it's fixed or not for next release).

    Thanks!

  9. lukehutch commented on Oct 2, 2023

    @lukehutch
    Author

    It doesn't seem to happen with any rhyme or reason, so I don't know that I can even produce a reproducer testcase for it. But I think there is something to be learned from the second stacktrace I gave in the original bug report: frames numbered 0 and 4-8 were not linked, but frames numbered 1-3 were linked. So it can even be some frames but not others in a single stacktrace that don't get linked. Therefore, it's not being caused by something like printing a stacktrace manually.

  10. lukehutch commented on Oct 15, 2023

    @lukehutch
    Author

    I got a video of this, although I don't know how to minimally reproduce this...

    The whole stacktrace appears as a single entry in the console (the whole thing highlights on mouse-over). The individual source files are not clickable.

    screen-recording-.2.mp4
  11. DanTup commented on Oct 16, 2023

    @DanTup
    Member

    @lukehutch are you certain this is an unhandled exception printed to stderr and not an exception that was caught and print()ed? I would expect it to be red if it was stderr. If it's coming via stdout when I think this is probably a dupe of #4711?

  12. lukehutch commented on Oct 16, 2023

    @lukehutch
    Author

    If somebody printed this, it wasn't me :-D Honestly I have no idea which IO channel this was printed to.

    I think this is in fact a dup of #4711, so I'll close in favor of that issue. Thanks!

  13. 16 remaining items

  14. lukehutch commented on Nov 2, 2023

    @lukehutch
    Author

    Ah, I was on the Flutter master channel a few times lately, but there was some breakage (I don't remember what), so I backed off, and I'm on beta now.

  15. lukehutch commented on Nov 14, 2023

    @lukehutch
    Author

    I tracked down the cause of one case where stacktraces are not auto-linked: this happens when the user calls stdout.writeln('$stackTrace'), which I think is the bug you linked previously.

    This doesn't account for some of the cases though where some frames are linked and some are not, within a single stacktrace, even though all code is in the same project.

  16. DanTup commented on Nov 14, 2023

    @DanTup
    Member

    @lukehutch are you testing with Flutter master? Do you have an example of unlinked frames that aren't a) printed via stdout and b) a _patch file? (those are both known issues.. the former needs to be fixed, the latter is not currently fixable).

  17. lukehutch commented on Nov 14, 2023

    @lukehutch
    Author

    @DanTup I'm on Flutter stable or beta (I switch back and forth). Master has had issues for my app.

    I don't have examples of frames that don't fit those two categories -- my previous comment was confirming that in some of the cases I have observed, the frames were printed to stdout (I finally caught all exceptions and drilled down to where the stacktrace was being sent to the console).

    The other examples I cited, where some stack frames were linked and others weren't, is probably from a patch file. Although I would like to see those frames labeled as such, so that it's obvious as to why they can't be linked. (And actually, even in those cases, it would be nice if a best-effort could be made to locate the actual source, since it's often there in the pub cache...)

    So you can go ahead and close this, if you think all the bases are covered.

  18. DanTup commented on Nov 15, 2023

    @DanTup
    Member

    I think the only issue not solved here is the patch files. I don't know if we can handle this (because I don't know if we can compute paths, and there may be multiple patch files for different platforms).

    But I'll keep this open to look at and at least figure out exactly what those issues are.

  19. modified the milestones: v3.78.0, On Deck on Nov 15, 2023
  20. changed the title [-]Dart-Code is not always able to parse stacktraces[/-] [+]Stack traces in the debug console do not show links for "_patch" files [/+] on Nov 15, 2023
  21. lukehutch commented on Nov 22, 2023

    @lukehutch
    Author

    I found one more area where code is not linked as it could/should be. This time, this is for output sent to stdout, and it's not stacktraces, it's the list of compilation errors that are given when you try to run code that has errors in it. The error lines are not linked:

    image

    It would be really helpful to have these lines linked.

  22. DanTup commented on Nov 22, 2023

    @DanTup
    Member

    @lukehutch thanks! Could you file a new issue for that one? I'm not sure how easily we can handle these ones, but it'll be a very different fix to the patch files. Thanks!

  23. lukehutch commented on Nov 23, 2023

    @lukehutch
    Author

    @DanTup I created #4853 for this. Thanks!

  24. DanTup commented on Feb 10, 2025

    @DanTup
    Member

    This was fixed recently, the frames are clickable - including _patch files:

    Image

  25. modified the milestones: On Deck, v3.106.0 on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsin flutterRelates to running Flutter appsis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions