Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when expanding local variable with Flutter Web #187

Open
Pacane opened this issue Dec 6, 2022 · 6 comments
Open

Error when expanding local variable with Flutter Web #187

Pacane opened this issue Dec 6, 2022 · 6 comments

Comments

@Pacane
Copy link

Pacane commented Dec 6, 2022

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
image

Version
Include here the result of: M-x lsp-dart-version
image

Here's the actual stacktrace

LSP :: Connected to [dart_analysis_server:2563275].
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:37141/packages/braver_flutter_domain_ui/src/pages/profile/sections/visibility/select_professions_search_capsule.dart.lib.js:155:15
    at Generator.next (<anonymous>)
    at runBody (http://localhost:37141/dart_sdk.js:40595:34)
    at Object._async [as async] (http://localhost:37141/dart_sdk.js:40626:7)
    at SearchCapsule.new.<anonymous> (http://localhost:37141/packages/braver_flutter_domain_ui/src/pages/profile/sections/visibility/select_professions_search_capsule.dart.lib.js:154:674)
    at SearchCapsule.new.triggerBuilder (http://localhost:37141/packages/braver_flutter_ui/src/themed_app.dart.lib.js:15279:74)
    at triggerBuilder.next (<anonymous>)
    at runBody (http://localhost:37141/dart_sdk.js:40595:34)
    at Object._async [as async] (http://localhost:37141/dart_sdk.js:40626:7)
    at SearchCapsule.new.triggerBuilder (http://localhost:37141/packages/braver_flutter_ui/src/themed_app.dart.lib.js:15277:22)
    at _MapStream.new.<anonymous> (http://localhost:37141/packages/braver_flutter_ui/src/themed_app.dart.lib.js:15144:286)
    at [_handleData] (http://localhost:37141/dart_sdk.js:38392:60)
    at [_handleData] (http://localhost:37141/dart_sdk.js:38300:37)
    at _rootRunUnary (http://localhost:37141/dart_sdk.js:40864:46)
    at async._CustomZone.new.runUnary (http://localhost:37141/dart_sdk.js:40047:14)
    at async._CustomZone.new.runUnaryGuarded (http://localhost:37141/dart_sdk.js:39967:14)
    at [_sendData] (http://localhost:37141/dart_sdk.js:34170:22)
    at _DelayedData.new.perform (http://localhost:37141/dart_sdk.js:37455:28)
    at _PendingEvents.new.handleNext (http://localhost:37141/dart_sdk.js:37592:15)
    at http://localhost:37141/dart_sdk.js:37564:16
    at _rootRun (http://localhost:37141/dart_sdk.js:40852:46)
    at async._CustomZone.new.run (http://localhost:37141/dart_sdk.js:40041:14)
    at async._CustomZone.new.runGuarded (http://localhost:37141/dart_sdk.js:39955:14)
    at http://localhost:37141/dart_sdk.js:40003:33
    at _rootRun (http://localhost:37141/dart_sdk.js:40858:14)
    at async._CustomZone.new.run (http://localhost:37141/dart_sdk.js:40041:14)
    at async._CustomZone.new.runGuarded (http://localhost:37141/dart_sdk.js:39955:14)
    at async._AsyncCallbackEntry.new.callback (http://localhost:37141/dart_sdk.js:40003:33)
    at Object._microtaskLoop (http://localhost:37141/dart_sdk.js:40705:13)
    at _startMicrotaskLoop (http://localhost:37141/dart_sdk.js:40711:13)
    at http://localhost:37141/dart_sdk.js:36447:9
  type: object
  value: null
attempted JS eval: ‘    (function() {
         var sdkUtils = require(’dart_sdk’).dart;
   var library = sdkUtils.getLibrary(’package:braver_flutter_ui/src/components/forms/search_capsule.dart’);
   if (!library) throw ’cannot find library for package:braver_flutter_ui/src/components/forms/search_capsule.dart’;
  
      var result = {};
      var clazz = library["_$36_Closed"];
      var descriptor = {
          ’name’: clazz.name,
          ’dartName’: sdkUtils.typeName(clazz)
        };

      // TODO(grouma) - we display all inherited methods since we don’t provide
      // the superClass information. This is technically not correct.
      var proto = clazz.prototype;
      var methodNames = [];
      for (; proto != null; proto = Object.getPrototypeOf(proto)) {
        var methods = Object.getOwnPropertyNames(proto);
        for (var i = 0; i < methods.length; i++) {
          if (methodNames.indexOf(methods[i]) == -1
              && methods[i] != ’constructor’) {
              methodNames.push(methods[i]);
          }
        }
        if (proto.constructor.name == ’Object’) break;
      }

      descriptor[’methods’] = {};
      for (var name of methodNames) {
        descriptor[’methods’][name] = {
          // TODO(jakemac): how can we get actual const info?
          "isConst": false,
          "isStatic": false,
        }
      }

      var fields = sdkUtils.getFields(clazz);
      var fieldNames = fields ? Object.keys(fields) : [];
      descriptor[’fields’] = {};
      for (var name of fieldNames) {
        var field = fields[name];
        var libraryUri = Object.getOwnPropertySymbols(fields[name]["type"])
        .find(x => x.description == "libraryUri");
        descriptor[’fields’][name] = {
          // TODO(jakemac): how can we get actual const info?
          "isConst": false,
          "isFinal": field.isFinal,
          "isStatic": false,
          "classRefName": fields[name]["type"]["name"],
          "classRefDartName": sdkUtils.typeName(fields[name]["type"]),
          "classRefLibraryId" : field["type"][libraryUri],
        }
      }

      // TODO(elliette): The following static member information is minimal and 
      // should be replaced once DDC provides full symbol information (see 
      // https://github.com/dart-lang/sdk/issues/40273):

      descriptor[’staticFields’] = {};
      var staticFieldNames = sdkUtils.getStaticFields(clazz) ?? [];
      for (const name of staticFieldNames) {
        descriptor[’staticFields’][name] = {
          "isStatic": true,
          // DDC only provides names of static members, we set isConst/isFinal 
          // to false even though they could be true.
          "isConst": false,
          "isFinal": false,
        }
      }

      descriptor[’staticMethods’] = {};
      var staticMethodNames = sdkUtils.getStaticMethods(clazz) ?? [];
      for (var name of staticMethodNames) {
        descriptor[’methods’][name] = {
          // DDC only provides names of static members, we set isConst
          // to false even though it could be true.
          "isConst": false,
          "isStatic": true,
        } 
      }

      return descriptor;
    })()
    ‘

#0      ClassHelper._constructClass (package:dwds/src/debugging/classes.dart:178:7)
<asynchronous suspension>
#1      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:125:47)
<asynchronous suspension>
@ericdallo
Copy link
Member

Looks like that exception comes from the DAP debugger server, any thoughts @DanTup?

@DanTup
Copy link

DanTup commented Dec 6, 2022

Based on the call stack and the code snippet (which seems to be coming from https://github.com/dart-lang/webdev/blob/84e197e2d75809281686b98e7507fb08b46fd18d/dwds/lib/src/debugging/classes.dart) I think the error is occurring in DWDS (which implements a Dart VM Service protocol over JavaScript/Chrome for debugging web apps).

I would suggest filing an issue with these details at https://github.com/dart-lang/webdev (which is the repo for DWDS), although it's curious that this doesn't occur in VS Code. It's possible that you're using the old legacy DAPs in VS Code and maybe they behave slightly differently? You can force the new SDK DAPs in VS Code by adding "dart.previewSdkDaps": true to your VS Code user settings.

@Pacane
Copy link
Author

Pacane commented Dec 6, 2022

Just to be clear, I haven't personally tried on VSCode, but I have asked colleagues if it worked. I could try to install VSCode myself and try it (I'm not using it normally, I'm using IntelliJ mostly)

@DanTup
Copy link

DanTup commented Dec 6, 2022

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.

@Pacane
Copy link
Author

Pacane commented Dec 7, 2022

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.

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)
    at BlocBuilder.new.<anonymous> (http://localhost:38069/packages/repro_lsp/main.dart.lib.js:442:642)
    at BlocBuilder.new.build (http://localhost:38069/packages/flutter_bloc/src/multi_bloc_listener.dart.lib.js:803:21)
    at _BlocBuilderBaseState.new.build (http://localhost:38069/packages/flutter_bloc/src/multi_bloc_listener.dart.lib.js:892:288)
    at framework.StatefulElement.new.build (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61935:25)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29540:22)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.MultiChildRenderObjectElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.MultiChildRenderObjectElement.new.updateChildren (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25687:44)
    at framework.MultiChildRenderObjectElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:30068:36)
    at framework.SingleChildRenderObjectElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.SingleChildRenderObjectElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:39631:31)
    at framework.StatelessElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatelessElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatelessElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatelessElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61916:12)
    at framework.StatelessElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatelessElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatelessElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatelessElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61916:12)
    at framework.InheritedElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.InheritedElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.InheritedElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.InheritedElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at ParentDataElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at ParentDataElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at ParentDataElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at ParentDataElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.MultiChildRenderObjectElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.MultiChildRenderObjectElement.new.updateChildren (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25687:44)
    at framework.MultiChildRenderObjectElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:30068:36)
    at framework.InheritedElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.InheritedElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.InheritedElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.InheritedElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.InheritedElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.InheritedElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.InheritedElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.InheritedElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.SingleChildRenderObjectElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.SingleChildRenderObjectElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:39631:31)
    at _NotificationElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at _NotificationElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at _NotificationElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at _NotificationElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.SingleChildRenderObjectElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.SingleChildRenderObjectElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:39631:31)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.InheritedElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.InheritedElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.InheritedElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.InheritedElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at _NotificationElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at _NotificationElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at _NotificationElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at _NotificationElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at _NotificationElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at _NotificationElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at _NotificationElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at _NotificationElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.InheritedElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.InheritedElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.InheritedElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.InheritedElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29626:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.StatefulElement.new.update (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61997:12)
    at framework.StatefulElement.new.updateChild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:24844:17)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:29563:33)
    at framework.StatefulElement.new.performRebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61976:13)
    at framework.StatefulElement.new.rebuild (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:25424:12)
    at framework.BuildOwner.new.buildScope (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:61386:21)
    at binding$5.WidgetsFlutterBinding.new.drawFrame (http://localhost:38069/packages/flutter/src/widgets/title.dart.lib.js:64198:43)
    at [_handlePersistentFrameCallback] (http://localhost:38069/packages/flutter/src/rendering/view.dart.lib.js:712:12)
    at [_invokeFrameCallback] (http://localhost:38069/packages/flutter/src/scheduler/binding.dart.lib.js:782:9)
    at binding$5.WidgetsFlutterBinding.new.handleDrawFrame (http://localhost:38069/packages/flutter/src/scheduler/binding.dart.lib.js:749:37)
    at [_handleDrawFrame] (http://localhost:38069/packages/flutter/src/scheduler/binding.dart.lib.js:696:12)
    at Object.invoke (http://localhost:38069/dart_sdk.js:196986:7)
    at _engine.EnginePlatformDispatcher.new.invokeOnDrawFrame (http://localhost:38069/dart_sdk.js:172327:15)
    at http://localhost:38069/dart_sdk.js:196709:57
    at Object._checkAndCall (http://localhost:38069/dart_sdk.js:5438:16)
    at Object.dcall (http://localhost:38069/dart_sdk.js:5443:17)
    at ret (http://localhost:38069/dart_sdk.js:62137:21)
  type: object
  value: null
attempted JS eval: ‘    (function() {
         var sdkUtils = require(’dart_sdk’).dart;
   var library = sdkUtils.getLibrary(’package:repro_lsp/bloc.dart’);
   if (!library) throw ’cannot find library for package:repro_lsp/bloc.dart’;
  
      var result = {};
      var clazz = library["_$36_MyStateWithValue"];
      var descriptor = {
          ’name’: clazz.name,
          ’dartName’: sdkUtils.typeName(clazz)
        };

      // TODO(grouma) - we display all inherited methods since we don’t provide
      // the superClass information. This is technically not correct.
      var proto = clazz.prototype;
      var methodNames = [];
      for (; proto != null; proto = Object.getPrototypeOf(proto)) {
        var methods = Object.getOwnPropertyNames(proto);
        for (var i = 0; i < methods.length; i++) {
          if (methodNames.indexOf(methods[i]) == -1
              && methods[i] != ’constructor’) {
              methodNames.push(methods[i]);
          }
        }
        if (proto.constructor.name == ’Object’) break;
      }

      descriptor[’methods’] = {};
      for (var name of methodNames) {
        descriptor[’methods’][name] = {
          // TODO(jakemac): how can we get actual const info?
          "isConst": false,
          "isStatic": false,
        }
      }

      var fields = sdkUtils.getFields(clazz);
      var fieldNames = fields ? Object.keys(fields) : [];
      descriptor[’fields’] = {};
      for (var name of fieldNames) {
        var field = fields[name];
        var libraryUri = Object.getOwnPropertySymbols(fields[name]["type"])
        .find(x => x.description == "libraryUri");
        descriptor[’fields’][name] = {
          // TODO(jakemac): how can we get actual const info?
          "isConst": false,
          "isFinal": field.isFinal,
          "isStatic": false,
          "classRefName": fields[name]["type"]["name"],
          "classRefDartName": sdkUtils.typeName(fields[name]["type"]),
          "classRefLibraryId" : field["type"][libraryUri],
        }
      }

      // TODO(elliette): The following static member information is minimal and 
      // should be replaced once DDC provides full symbol information (see 
      // https://github.com/dart-lang/sdk/issues/40273):

      descriptor[’staticFields’] = {};
      var staticFieldNames = sdkUtils.getStaticFields(clazz) ?? [];
      for (const name of staticFieldNames) {
        descriptor[’staticFields’][name] = {
          "isStatic": true,
          // DDC only provides names of static members, we set isConst/isFinal 
          // to false even though they could be true.
          "isConst": false,
          "isFinal": false,
        }
      }

      descriptor[’staticMethods’] = {};
      var staticMethodNames = sdkUtils.getStaticMethods(clazz) ?? [];
      for (var name of staticMethodNames) {
        descriptor[’methods’][name] = {
          // DDC only provides names of static members, we set isConst
          // to false even though it could be true.
          "isConst": false,
          "isStatic": true,
        } 
      }

      return descriptor;
    })()
    ‘

#0      ClassHelper._constructClass (package:dwds/src/debugging/classes.dart:178:7)
<asynchronous suspension>
#1      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:125:47)
<asynchronous suspension>

Hopefully that'll help!

@DanTup
Copy link

DanTup commented Dec 7, 2022

I do see the same issue in VS Code:

Screenshot 2022-12-07 at 13 24 58

[13:26:26] [VmService] [Info] [Flutter (Chrome)] ==> {"id":"25","jsonrpc":"2.0","method":"getObject","params":{"isolateId":"1","objectId":"classes|package:repro_lsp/bloc.dart|_$36_MyStateWithValue"}}

[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <== [+25202 ms] AppInspector: getObject classes|package:repro_lsp/bloc.dart|_$36_MyStateWithValue failedError: Unexpected error from chrome devtools:
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==             text: Uncaught
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==             exception:
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==               preview: null
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==               description: TypeError: Cannot read properties of undefined (reading 'name')
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at <anonymous>:9:25
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at <anonymous>:83:7
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at http://localhost:53618/packages/repro_lsp/main.dart.lib.js:454:810
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at bloc$._$_MyStateWithValue.new.when (http://localhost:53618/packages/repro_lsp/bloc.dart.lib.js:560:14)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at BlocBuilder.new.<anonymous> (http://localhost:53618/packages/repro_lsp/main.dart.lib.js:454:642)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at BlocBuilder.new.build (http://localhost:53618/packages/flutter_bloc/src/multi_bloc_listener.dart.lib.js:807:21)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at _BlocBuilderBaseState.new.build (http://localhost:53618/packages/flutter_bloc/src/multi_bloc_listener.dart.lib.js:896:288)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at framework.StatefulElement.new.build (http://localhost:53618/packages/flutter/src/widgets/title.dart.lib.js:67601:25)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at framework.StatefulElement.new.performRebuild (http://localhost:53618/packages/flutter/src/widgets/title.dart.lib.js:21885:22)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at framework.StatefulElement.new.performRebuild (http://localhost:53618/packages/flutter/src/widgets/title.dart.lib.js:67637:13)
[13:26:26] [FlutterRun] [Info] [Flutter (Chrome)] <==                 at framework.StatefulElement.new.rebuild (http://localhost:53618/packages/flutter/src/widgets/title.dart.lib.js:17571:12)

The line/col in the errr at the top of the stack looks like this:

Screenshot 2022-12-07 at 13 35 51

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants