Repository navigation
"Global evaluation not currently supported" message is unclear and DAP errors include verbose stack traces #4899
Copy link
Copy link
Closed
Labels
in debuggingRelates to the debug adapter or process of running debug sessionsRelates to the debug adapter or process of running debug sessionsis bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become availableSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
Milestone
Description
Describe the bug
If you try to enter a debug expression when the debugger is not running, you get UnimplementedError, with a big ugly stacktrace. Probably only the error message itself should be shown.
UnimplementedError: Global evaluation not currently supported without a Dart script context
#0 DartDebugAdapter.evaluateRequest (package:dds/src/dap/adapters/dart.dart:980:7)
#1 BaseDebugAdapter.handle (package:dds/src/dap/base_debug_adapter.dart:141:20)
#2 BaseDebugAdapter.handleIncomingRequest (package:dds/src/dap/base_debug_adapter.dart:460:7)
#3 BaseDebugAdapter._handleIncomingMessage (package:dds/src/dap/base_debug_adapter.dart:301:7)
#4 ByteStreamServerChannel._readMessage (package:dds/src/dap/protocol_stream.dart:82:18)
#5 ByteStreamServerChannel.listen.<anonymous closure> (package:dds/src/dap/protocol_stream.dart:53:24)
#6 _rootRunUnary (dart:async/zone.dart:1407:47)
#7 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
#8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#10 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#11 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#12 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#13 _rootRun (dart:async/zone.dart:1391:47)
#14 _CustomZone.run (dart:async/zone.dart:1301:19)
#15 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#16 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249:23)
#17 _rootRun (dart:async/zone.dart:1399:13)
#18 _CustomZone.run (dart:async/zone.dart:1301:19)
#19 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#20 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249:23)
#21 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#22 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#23 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#24 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
To Reproduce
Steps to reproduce the behavior:
- Type something into the debug console's input line when the debugger is not running
Workspace Environment
Dart Code extension: 3.79.20231206
Flutter extension: 3.79.20231130 (activated)
App: Visual Studio Code
App Host: desktop
Version: linux 1.85.1
Workspace type: Dart, Flutter (LSP) (Multiroot)
Dart (3.3.0-174.3.beta): /opt/flutter/bin/cache/dart-sdk
Flutter (3.18.0-0.2.pre): /opt/flutter (Chrome (web-javascript/web))
Output from 'dart info'
/opt/flutter/bin/cache/dart-sdk/bin/dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
General info
- Dart 3.3.0-174.3.beta (beta) (Tue Dec 12 14:49:22 2023 +0000) on "linux_x64"
- on linux / Linux 6.5.12-300.fc39.x86_64 Code already includes yaml support, doesn't need providing #1 SMP PREEMPT_DYNAMIC Mon Nov 20 22:44:24 UTC 2023
- locale is en_US.utf8
Project info
- sdk constraint: '>=3.1.5 <4.0.0'
- dependencies: auto_size_text, boxy, cached_network_image, carousel_slider, collection, cross_file, cupertino_icons, device_info_plus, email_validator, exif, extended_image, flutter, flutter_cache_manager, flutter_email_sender, flutter_fgbg, flutter_image_utilities, flutter_localizations, flutter_persistent_value_notifier, flutter_svg, fluttericon, fluttertoast, geocoding, geolocator, getwidget, google_fonts, google_mlkit_face_detection, http, image_picker, intl, jiffy, line_awesome_flutter, logging, material_dialogs, package_info_plus, path_provider, persistent_bottom_nav_bar_v2, provider, random_string, share_plus, shared_preferences, url_launcher
- dev_dependencies: flutter_launcher_icons, flutter_lints, flutter_test, lints
- elided dependencies: 11
Process info
| Memory | CPU | Elapsed time | Command line |
|---|---|---|---|
| 522 MB | 0.0% | 06:01:35 | dart --enable-vm-service=0 --pause_isolates_on_start --disable-dart-dev -DSILENT_VM_SERVICE=true --write-service-info=file:/vm.json --pause_isolates_on_exit --enable-asserts /main.dart |
| 687 MB | 1.1% | 47:50 | dart ../serverpod_cli.dart generate --watch |
| 673 MB | 7.1% | 07:00 | dart ../serverpod_cli.dart generate --watch |
| 75 MB | 0.0% | 06:01:35 | dart debug_adapter |
| 60 MB | 0.0% | 10:12:55 | dart devtools --machine --allow-embedding |
| 59 MB | 0.0% | 10:12:48 | dart devtools --machine --allow-embedding |
| 2172 MB | 2.7% | 10:12:55 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.79.20231206 |
| 1533 MB | 0.3% | 10:12:48 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.79.20231206 |
| 91 MB | 0.0% | 10:12:55 | flutter_tools.snapshot daemon |
| 90 MB | 0.0% | 10:12:48 | flutter_tools.snapshot daemon |
Output from 'flutter doctor'
/opt/flutter/bin/flutter doctor -v
[✓] Flutter (Channel beta, 3.18.0-0.2.pre, on Fedora Linux 39 (Workstation Edition) 6.5.12-300.fc39.x86_64, locale en_US.utf8)
• Flutter version 3.18.0-0.2.pre on channel beta at /opt/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fed06b31d9 (3 days ago), 2023-12-13 14:53:33 -0800
• Engine revision 39c6dc9bdd
• Dart version 3.3.0 (build 3.3.0-174.3.beta)
• DevTools version 2.30.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /home/luke/Android/Sdk
• Platform android-34, build-tools 33.0.1
• Java binary at: /opt/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 17.0.4 (Fedora 17.0.4-1.fc39)
• cmake version 3.27.7
• ninja version 1.11.1
• pkg-config version 1.9.5
[✓] Android Studio (version 2022.2)
• Android Studio at /opt/android-studio
• Flutter plugin version 73.0.2
• Dart plugin version 222.4582
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.85.1)
• VS Code at /usr/share/code
• Flutter extension version 3.79.20231130
[✓] VS Code (version 1.86.0-insider)
• VS Code at /usr/share/code-insiders
• Flutter extension version 3.79.20231130
[✓] Connected device (3 available)
• sdk gphone x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Linux (desktop) • linux • linux-x64 • Fedora Linux 39 (Workstation Edition) 6.5.12-300.fc39.x86_64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.159
[✓] Network resources
• All expected network resources are available.
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in debuggingRelates to the debug adapter or process of running debug sessionsRelates to the debug adapter or process of running debug sessionsis bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become availableSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
Activity
DanTup commentedon Dec 18, 2023
@lukehutch can you clarify what you mean by "when the debugger is not running" here? The error here is coming from the debug adapter, so I wouldn't expect you can trigger this without being in a debug session.
There is some code to try and provide a context for you to handle this - I wonder whether it's because you don't have any open files or something?
We should definitely shouldn't show a full stack like this for that error message 😔
DanTup commentedon Dec 18, 2023
I can repro this with no open files. Response looks like this:
@helin24 I think this started happening with dart-lang/sdk@aa9a219 because of this:
We could change this to:
But it's not clear to me if a) that will break anything for you or b) if it's weird to include the stack inside
variablesbut not use it there.Another option could be to not include the stack for
DebugAdapterExceptions, or a new sub-class of that designed for user-friendly messages where the stack isn't important (it's not a crash, but an error condition we just want to provide a message for). I don't know what split of the existingDebugAdapterExceptions would go into each camp but I suspect the majority (if not all) are probably intended as user-messages and the stack isn't useful.helin24 commentedon Dec 18, 2023
@DanTup I looked back at why we made this change initially and I think it will be okay to remove the stack here. Mainly we just wanted to expand
bodyto be an object withid,format, andvariablesinstead of being a string.lukehutch commentedon Dec 18, 2023
I can't remember how I triggered this (I think I wasn't running anything at the time, but I can't repro that right now).
What I can repro right now is that typing anything into the debugging console input line when building an app before launch, or before stopping on a breakpoint after launch, gives this error.
DanTup commentedon Dec 19, 2023
@helin24 thanks! I'll leave it in the payload for debugging (since it was in the payload before your change), and just drop it from
variableswith an appropriate comment.@lukehutch I presume your active file is not Dart or you don't have an open file too? The condition for this is basically "we need a thread/frame or a file". You won't have a thread/frame when not paused so it'll try for a file.
In any case, my fix will make this message clearer and drop the stack:
lukehutch commentedon Dec 19, 2023
@DanTup That message is much better, but I can see there is already an effort to disable the input line when debugging ends. Shouldn't the disablement of the input line prevent that exception from ever being thrown?
(Sorry, I don't know what you mean by "active file", but it's possible I was viewing something else other than Dart at the time, yes -- I have yaml files in my project)
DanTup commentedon Dec 19, 2023
@lukehutch the debug console input box is not available when there is no debug session running (this is VS Code behaviour). For this code to execute, there must be a debug session (VS Code only creates our debug adapter when a debug session starts and terminates it when it ends).
When there is a running debug session, evaluation is only available when we have one of two things:
So it's very possible to trigger this path by not having any open files and not being paused when you try to evaluate (or, having your only open files by non-Dart files).
DanTup commentedon Dec 19, 2023
Fix is open at https://dart-review.googlesource.com/c/sdk/+/342621
DanTup commentedon Dec 19, 2023
I tweaked the text slightly to try to make it clearer about having a file open in the editor:
[-]`UnimplementedError: Global evaluation not currently supported without a Dart script context`[/-][+]"Global evaluation not currently supported" message is unclear and DAP errors include verbose stack traces[/+]lukehutch commentedon Dec 19, 2023
Well then shouldn't you make it impossible to type into the input field when one or both of those things is not available? This error should never be triggerable.
DanTup commentedon Dec 19, 2023
This is unfortunately not possible. We have no control over this part of the UI in VS Code - the only thing we can do is respond to the "evaluate request" when it's sent to the debug adapter.
lukehutch commentedon Dec 20, 2023
The input field is disabled once a debugging session ends though. Maybe it's worth requesting access to the API that enables or disables this field?
DanTup commentedon Dec 20, 2023
The field is disabled by VS Code, it's just based on whether there is a debug session.
I don't think it's likely we'd ever get APIs to handle this - we'd need more than just the ability to disable the input box - we'd also need access to know if you're paused (which we don't currently). The debug adapter is also running in another process (using a standard protocol that isn't specific to VS Code) so it would only be useful if we're running VS Code-specific code in the client too (in this case we are a little, but it's a workaround for getting the file - there's an open issue about getting a better way to do this at microsoft/vscode#134452).
So while it's not perfect, I think the current behaviour (with my improvements above) is the best we'll reaslitically get (at least until
evaluatehas some better support for current file contexts).[dds/dap] Don't show stack traces in error messages from DAP
DanTup commentedon Jan 22, 2024
dart-lang/sdk@793755f improved the error message and removed the verbose stack traces.
We can't disable the input box when there's no active file (as noted above), but it should be clear now when this fails because you're not paused and have no active Dart file.