flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.2k stars 27.49k forks source link

[flutter_tools] "(-32603) setIsolatePauseMode: NoSuchMethodError" with `flutter debug_adapter` #109250

Closed christopherfujino closed 2 years ago

christopherfujino commented 2 years ago

On stable/3.0.5 Command flutter debug_adapter

RPCError: setIsolatePauseMode: (-32603) setIsolatePauseMode: NoSuchMethodError: Class 'ChromeProxyService' has no instance method 'setIsolatePauseMode' with matching arguments.Receiver:

Instance of 'ChromeProxyService' Tried calling:
setIsolatePauseMode("1", exceptionPauseMode: "Unhandled", shouldPauseOnExit: null)
Found:
setIsolatePauseMode(String, {String exceptionPauseMode, bool shouldPauseOnExit}) => Future<Success>

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1      ChromeProxyService.noSuchMethod (package:dwds/src/services/chrome_proxy_service.dart:1042:18)
#2      ChromeProxyService.setIsolatePauseMode (package:dwds/src/services/chrome_proxy_service.dart:43:7)
#3      VmServerConnection._delegateRequest (package:vm_service/src/vm_service.dart:1597:51)
#4      StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
#5      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
#6      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
#7      _rootRunUnary (dart:async/zone.dart:1434:47)
#8      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#9      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#10     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#11     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#12     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#13     _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#14     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#15     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
#16     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
#17     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
#18     _rootRunUnary (dart:async/zone.dart:1434:47)
#19     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#21     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#22     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#23     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#24     _StreamController._add (dart:async/stream_controller.dart:648:7)
#25     _StreamController.add (dart:async/stream_controller.dart:596:5)
#26     new WebSocketImpl.fromSocket.<anonymous closure> (package:web_socket_channel/src/copy/web_socket_impl.dart:730:21)
#27     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
#28     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
#29     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
#30     _rootRunUnary (dart:async/zone.dart:1434:47)
#31     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#32     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#33     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#34     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#35     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#36     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#37     _WebSocketProtocolTransformer._messageFrameEnd (package:web_socket_channel/src/copy/web_socket_impl.dart:319:23)
#38     _WebSocketProtocolTransformer.add (package:web_socket_channel/src/copy/web_socket_impl.dart:218:46)
#39     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#40     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
#41     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
#42     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
#43     _rootRunUnary (dart:async/zone.dart:1434:47)
#44     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#45     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#46     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#47     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#48     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#49     _StreamController._add (dart:async/stream_controller.dart:648:7)
#50     _StreamController.add (dart:async/stream_controller.dart:596:5)
#51     _Socket._onData (dart:io-patch/socket_patch.dart:2314:41)
#52     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:26)
#53     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:208:15)
#54     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:126:14)
#55     _rootRunUnary (dart:async/zone.dart:1442:13)
#56     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#57     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#58     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#59     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#60     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#61     _StreamController._add (dart:async/stream_controller.dart:648:7)
#62     _StreamController.add (dart:async/stream_controller.dart:596:5)
#63     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1839:33)
#64     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#65     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#66     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#67     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
#68     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)

at new _OutstandingRequest(vm_service.dart:1734)
at VmService._call(vm_service.dart:2245)
at VmService.setIsolatePauseMode(vm_service.dart:2145)
at IsolateManager._sendExceptionPauseMode(isolate_manager.dart:655)
at IsolateManager._configureIsolate(isolate_manager.dart:348)
at IsolateManager.registerIsolate(isolate_manager.dart:205)
at DartDebugAdapter._configureExistingIsolates.<anonymous closure>(dart.dart:652)
at DartDebugAdapter._configureExistingIsolates.<anonymous closure>(dart.dart:645)
at MappedListIterable.elementAt(iterable.dart:413)
at ListIterator.moveNext(iterable.dart:342)
at Future.wait(future.dart:519)
at DartDebugAdapter._configureExistingIsolates(dart.dart:645)
at <asynchronous gap>(async)
at DartDebugAdapter._withErrorHandling(dart.dart:2039)
at <asynchronous gap>(async)
at DartDebugAdapter.connectDebugger(dart.dart:624)
at <asynchronous gap>(async)

Note that there is an entire Dart stacktrace on the first line, which is part of the Exception message

christopherfujino commented 2 years ago

cc @elliette and @DanTup, it looks like the debug addapter is not playing nice with dwds?

elliette commented 2 years ago

This looks like a null-safety incompatibility:

RPCError: setIsolatePauseMode: (-32603) setIsolatePauseMode: NoSuchMethodError: Class 'ChromeProxyService' has no instance method 'setIsolatePauseMode' with matching arguments.Receiver: Instance of 'ChromeProxyService'
Tried calling: setIsolatePauseMode("1", exceptionPauseMode: "Unhandled", shouldPauseOnExit: null)
Found: setIsolatePauseMode(String, {String exceptionPauseMode, bool shouldPauseOnExit}) => Future<Success>#0      

DWDS is now fully migrated to null-safety. I'm guessing doing a release of DWDS should resolve this, but let me confirm.

christopherfujino commented 2 years ago

This looks like a null-safety incompatibility:

RPCError: setIsolatePauseMode: (-32603) setIsolatePauseMode: NoSuchMethodError: Class 'ChromeProxyService' has no instance method 'setIsolatePauseMode' with matching arguments.Receiver: Instance of 'ChromeProxyService'Tried calling: setIsolatePauseMode("1", exceptionPauseMode: "Unhandled", shouldPauseOnExit: null)Found: setIsolatePauseMode(String, {String exceptionPauseMode, bool shouldPauseOnExit}) => Future<Success>#0      

DWDS is now fully migrated to null-safety. I'm guessing doing a release of DWDS should resolve this, but let me confirm.

ahh, good catch

christopherfujino commented 2 years ago

Assigning to myself to investigate

christopherfujino commented 2 years ago

the debug adapter code is coming from dds 2.2.0 vm_service 8.2.2 dwds 12.1.1

christopherfujino commented 2 years ago

From reading the code at https://github.com/dart-lang/webdev/blob/1931dc9daa61036ca7742cc6beca2bfbedeba75c/dwds/lib/src/services/chrome_proxy_service.dart, it actually seems like the dwds:12.1.1 version of ChromeProxyService doesn't even implement the .setIsolatePauseMode() method, but I don't know how this isn't a compiler error. It IS part of the VmServiceInterface that ChromeProxyService implements: https://github.com/dart-lang/sdk/blob/400bad75440e463b1fb584157df36415dd03afdd/pkg/vm_service/lib/src/vm_service.dart#L1108. I might be getting mixed up with my revision hashes...

elliette commented 2 years ago

Ah okay. DWDS v12.1.1 doesn't have the setIsolatePauseMode method, that was added in v14.0.3: https://github.com/dart-lang/webdev/blob/master/dwds/CHANGELOG.md#1403

Here was the tracking issue for that: https://github.com/dart-lang/webdev/issues/1627

Trying to think of the best way to resolve this (I don't think we want to cherrypick in v14.0.3 of DWDS since there are a lot of changes between that and v12.1.1

christopherfujino commented 2 years ago

Ah okay. DWDS v12.1.1 doesn't have the setIsolatePauseMode method, that was added in v14.0.3: https://github.com/dart-lang/webdev/blob/master/dwds/CHANGELOG.md#1403

Here was the tracking issue for that: dart-lang/webdev#1627

Trying to think of the best way to resolve this (I don't think we want to cherrypick in v14.0.3 of DWDS since there are a lot of changes between that and v12.1.1

I'm stumped on how this compiles though, since it seems to me like the version of vm_service we're using includes this method in the interface we're implementing.

christopherfujino commented 2 years ago

Trying to think of the best way to resolve this (I don't think we want to cherrypick in v14.0.3 of DWDS since there are a lot of changes between that and v12.1.1

Fortunately our beta branch is beyond this, I think we're ok not backporting to stable: https://github.com/flutter/flutter/blob/beta/packages/flutter_tools/pubspec.yaml#L14

christopherfujino commented 2 years ago

Ah okay. DWDS v12.1.1 doesn't have the setIsolatePauseMode method, that was added in v14.0.3: https://github.com/dart-lang/webdev/blob/master/dwds/CHANGELOG.md#1403 Here was the tracking issue for that: dart-lang/webdev#1627 Trying to think of the best way to resolve this (I don't think we want to cherrypick in v14.0.3 of DWDS since there are a lot of changes between that and v12.1.1

I'm stumped on how this compiles though, since it seems to me like the version of vm_service we're using includes this method in the interface we're implementing.

Oh nevermind, it still compiles because there's a noSuchMethod method implemented.

christopherfujino commented 2 years ago

Closing this as a duplicate of https://github.com/dart-lang/webdev/issues/1627 which was fixed upstream, including in the current 3.3 beta.

DanTup commented 2 years ago

Isn't the issue here that the method signature doesn't match because shouldPauseOnExit is not nullable in the current (released) DWDS rather than it being missing?

If so, it looks like that is fixed much more recently by https://github.com/dart-lang/webdev/pull/1687 which isn't in a DWDS release yet?

christopherfujino commented 2 years ago

Isn't the issue here that the method signature doesn't match because shouldPauseOnExit is not nullable in the current (released) DWDS rather than it being missing?

If so, it looks like that is fixed much more recently by dart-lang/webdev#1687 which isn't in a DWDS release yet?

looks can be deceiving. I initially thought this, however I'm pretty sure that the real issue is that our version of dwds and thus ChromeProxyService does not implement the method at all; it still compiles because it implements noSuchMethod, which is at the top of our stacktrace.

christopherfujino commented 2 years ago

Isn't the issue here that the method signature doesn't match because shouldPauseOnExit is not nullable in the current (released) DWDS rather than it being missing?

This is happening on stable, not the currently released dwds.

DanTup commented 2 years ago

I initially thought this, however I'm pretty sure that the real issue is that our version of dwds and thus ChromeProxyService does not implement the method at all; it still compiles because it implements noSuchMethod

Oh, weird. The "Found" line seems to match the signature of the current release:

Instance of 'ChromeProxyService' Tried calling: setIsolatePauseMode("1", exceptionPauseMode: "Unhandled", shouldPauseOnExit: null) Found: setIsolatePauseMode(String, {String exceptionPauseMode, bool shouldPauseOnExit}) => Future

Although it occurs to me now that before the PR linked above, the file was marked as // @dart = 2.9 so I think the argument would be implicitly nullable anyway, so shouldn't cause this type of error.

I'll make a note to double check this on beta tomorrow anyway. I don't recall how much testing I did with a web device, and with DWDS there's a lot of different code running compared to the VM.

christopherfujino commented 2 years ago

Oh, weird. The "Found" line seems to match the signature of the current release:

Instance of 'ChromeProxyService' Tried calling: setIsolatePauseMode("1", exceptionPauseMode: "Unhandled", shouldPauseOnExit: null) Found: setIsolatePauseMode(String, {String exceptionPauseMode, bool shouldPauseOnExit}) => Future

I think what is happening is that the "Found" refers to the interface type, however this is not an implementation, but a declaration without a body. FWIW, the interface implementation has a nullable bool?.

DanTup commented 2 years ago

I tested on current beta and indeed this is working fine (it doesn't have the latest DWDS null safety changes, but the library is marked as 2.9 so is implicitly nullable):

[8:57:16 AM] [DAP] [Info] ==> {"command":"setExceptionBreakpoints","arguments":{"filters":["All","Unhandled"]},"type":"request","seq":11}
[8:57:16 AM] [General] [Info] [Flutter (Chrome)] ==> [VM] {"jsonrpc":"2.0","id":"623","method":"setIsolatePauseMode","params":{"isolateId":"1","exceptionPauseMode":"All"}}
[8:57:16 AM] [General] [Info] [Flutter (Chrome)] <== [VM] {"jsonrpc":"2.0","result":{"type":"Success"},"id":"623"}

So it does seem all is good and there's nothing to do, sorry for the diversion!

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.