Open Pacane opened 1 year ago
cc: @kevmoo @DanTup
@DanTup feel free to add any details I could have missed. thanks!
@jacob314 – can you help route? I don't think this has to do w/ pkg:webdev
The thrown error starts with "Unexpected error from chrome devtools" so my feeling was that this might be something not being handled correctly in DWDS (although I also couldn't find the code trying to read name
so I'm not sure if it's triggered by user code, or something in the generated JS).
Usually when an expression evaluation fails, there's an exception returned from the evaluateInFrame
call that we display in the watch window. That is happening here, but the error message doesn't look like something the user would understand (if it is being caused by their code), but it's also being written to the flutter run
output, so it fills the debug console (this is unexpected, the error should be confined to the response to the evaluateInFrame
request over the VM Service).
dap-request: getObject: (-32603) getObject: Unexpected error from chrome devtools:
text: Uncaught
exception:
description: TypeError: Cannot read properties of undefined (reading ’name’)
at <anonymous>:9:25
at <anonymous>:83:7
at http://localhost:38069/packages/repro_lsp/main.dart.lib.js:442:810
at bloc$._$_MyStateWithValue.new.when (http://localhost:38069/packages/repro_lsp/bloc.dart.lib.js:556:14)
I'm able to reproduce this when debugging from VSCode, but not when debugging with Flutter DevTools (expanding _state
does not show an error), which makes me think there is some difference in how they are calling this.
It looks like the error is coming from here: https://github.com/dart-lang/webdev/blob/3e2364ee3539ae08f350d03a3a5f3c22aa74d994/dwds/lib/src/debugging/inspector.dart#L392. The objectId
seems strange to me:
classes|package:repro_lsp/bloc.dart|_$36_MyStateWithValue
@DanTup, is there a way to specify the Flutter SDK in VSCode to be my local Flutter to help debug? Thanks!
@elliette you can use the dart.flutterSdkPath
setting to specify a Flutter SDK, although I'm not sure if that's exactly what you mean since you probably only have one Flutter SDK checked out anyway? If you do have multiple, you can also set dart.flutterSdkPaths
(note the plural) to let you easily switch between them from the status bar (it's an array of paths, although if you have multiple SDKs inside the same parent folder, you can just list the parent folder here as we search 1 level deep).
I've reported an exception I've gotten while using emacs with lsp-dart here.
Turns out @DanTup was able to reproduce it with my repro project using VSCode. He directed me here to open an issue as it seems to be an issue a bit deeper than just the lsp plugin I'm using. I'll try to describe as best as possible was was discussed in the other issue here.
Describe the bug When expanding a local variable (not happening with all variables), in the DAP ui mode, I get an exception.
For reference, I tried expanding the variable searchState in my case. And for more context, I'm able to inspect such variables in IntelliJ and VSCode.
To Reproduce I'm using a closed source project, but what I'm doing specifically is trying to expand a variable that's passed as a closure, which has for type a Freezed union type value.
Expected behavior It would expand the thing normally.
Screenshots
Version Include here the result of: M-x lsp-dart-version
Here's the actual stacktrace
@DanTup asked for repro steps and gave some context:
IntelliJ should generally behave the same here too. The DAP used by VS Code (and emacs here) is just wrapping the VM Service which IntelliJ also uses. It's very possible (even likely) there are some differences in how it fetches and renders data for variables, although something like this seems like it should show up in both.
If you're able to build a small repro you can share that triggers the issue I'm happy to take a look too. A full DAP traffic log would be useful too (using the same sharable repro), in case I can't reproduce it myself.
Then I posted my repro steps
There you go https://github.com/Pacane/lsp_repro
Just a bit of context for the app (tried to replicate as much of what I'm doing in my real project).
It's the regular counter app, but with a bloc to hold a value state. The state and events of the bloc are actual Freezed classes (events are union types and state is a freezed immutable object).
There's a bloc builder in the main app that renders a Text widget with the value held in the bloc.
If you add a breakpoint on the line 79 (return line), and expand bloc -> _state in the dap UI locals, you do get the error I posted earlier.
Then , @DanTup replied
I do see the same issue in VS Code:
The line/col in the errr at the top of the stack looks like this:
Unfortunately I'm not sure how to attach a JS debugger to the expressions being evaluated by DWDS here. My feeling is that there's a DWDS bug here - even if the trigger is an exception in user code, it doesn't seem like it should be failing in this way.
Given you have a good repro, I would suggest filing an issue at https://github.com/dart-lang/webdev with the repro steps above (you can link back here for some additional context, and feel free to CC me in case I can add any value).