analysis_server using different analyzer_plugin package than the plugin I'm developing?

97 views
Skip to first unread message

Claudiu

unread,
Mar 13, 2023, 11:33:18 AM3/13/23
to Dart Analyzer Discussion
Howdy!

I'm developing an analyzer plugin for the first time, so I may be missing a glaringly obvious thing I'm doing wrong, but I've had the plugin working until a few days ago. I started developing it about a week ago but, recently, I've been getting an Exception in the Plugin section of the Analysis Server Diagnostics page:

Exception: Expected isCompatible at result
#0 new PluginVersionCheckResult.fromJson (package:analyzer_plugin/protocol/protocol_generated.dart:3526:9)
#1 new PluginVersionCheckResult.fromResponse (package:analyzer_plugin/protocol/protocol_generated.dart:3562:37)
#2 PluginSession.start (package:analysis_server/src/plugin/plugin_manager.dart:987:43)
#3 PluginInfo.start (package:analysis_server/src/plugin/plugin_manager.dart:219:21)
#4 PluginManager.addPluginToContextRoot (package:analysis_server/src/plugin/plugin_manager.dart:344:23)

What's interesting is that, while using the proxy server debugging method described here, I no longer have problems in that section, but I do get exceptions in the Exceptions section when the plugin sends notifications (so, the server no longer crashes on version check, I think):

Exception type '_Map<String, dynamic>' is not a subtype of type 'Map<String, Object>' in type cast
Socket error: type '_Map<String, dynamic>' is not a subtype of type 'Map<String, Object>' in type cast

fatal: false
#0 new Notification.fromJson (package:analyzer_plugin/protocol/protocol.dart:43:35)
#1 ServerIsolateChannel.listen.<anonymous closure> (package:analyzer_plugin/src/channel/isolate_channel.dart:234:39)
#2 _rootRunUnary (dart:async/zone.dart:1414:13)
#3 _CustomZone.runUnary (dart:async/zone.dart:1307:19)
#4 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1216:7)
#5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#7 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#8 _StreamController._add (dart:async/stream_controller.dart:648:7)
#9 _StreamController.add (dart:async/stream_controller.dart:596:5)
#10 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

Going back to the scenario where I don't use the proxy server debugging method, when looking at package:analyzer_plugin/protocol/protocol_generated.dart in my .pub-cache, I see that PluginVersionCheckResult.fromJson is not on line 3526 (like the isCompatible exception says), but on line 3669, which leads me to believe that there are breaking inconsistencies between the analysis_plugin package bundled with the Dart SDK and what pub pulls into my plugin package.

I'm working with a Flutter global installation through fvm by using Sidekick. Currently on Flutter stable 3.7.7 with Dart 2.19.4.

1. Any ideas how I should carry on?
2. Has this message been too long?

I've attached some .yaml files for my setup, in case they're of any help. The Flutter testing app depends on my_analyzer_plugin. The plugin contains the bootstrap package, as specified here. What differs in my case is that the plugin package is merged into the host package.

Thanks a bunch!

target_analysis_options.yaml
host_pubspec.yaml
target_pubspec.yaml
bootstrap_pubspec.yaml
host_analysis_options.yaml

Brian Wilkerson

unread,
Mar 16, 2023, 4:15:47 PM3/16/23
to analyzer...@dartlang.org
Sorry for the long delay; we've been heads-down on Dart 3.0 work, so some other things have fallen behind.

I'm developing an analyzer plugin for the first time ...

Just to make sure that you're aware: the plugin mechanism is a proof-of-concept prototype that isn't formally supported. We actively discourage users from using it, and can't make any guarantees about the future of the mechanism. I can say that it seems highly unlikely that it will continue in its current form, and there's no guarantee that if we decide to support some kind of mechanism in the future that the new mechanism will be compatible with the current mechanism in any way.

I started developing it about a week ago but, recently, I've been getting an Exception in the Plugin section of the Analysis Server Diagnostics page

Unless you missed the exception earlier, that would suggest that something in your code changed such that the exception started being thrown. If you can write a test that will trigger the exception, then you might be able to bisect to find when the failure mode was introduced.

Exception: Expected isCompatible at result

That would indicate that the json being sent from the plugin doesn't have a key named `isCompatible`. If you enable the instrumentation log you can see what the json looks like and that might give you a better idea of what's happening.

... while using the proxy server debugging method described here ...

I'm not familiar with that tool, so I don't know what it does that might cause the behavior to change. Simon might know, so you might try pinging him.

... which leads me to believe that there are breaking inconsistencies between the analysis_plugin package bundled with the Dart SDK and what pub pulls into my plugin package.

It's normal for a plugin to be using different versions of packages than those being used by the analysis server that's running it. The plugins are run in separate isolates, so they don't share any memory with the isolate running the analysis server. The only thing that matters is that the protocol you're using is the same as the protocol that the server is running. Given that the protocol hasn't changed for a very long time, that's unlikely to be the source of the problem.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/analyzer-discuss/eac7ce7f-123b-42b3-988a-2d2c4f930fd4n%40dartlang.org.

Claudiu

unread,
Mar 20, 2023, 1:10:39 PM3/20/23
to Dart Analyzer Discussion, brianwilkerson
No worries. I imagine you have little time to spend on these kinds of issues. I'm aware you don't officially support 3rd party analyzer plugins, so I appreciate you guys taking the time to respond to folks such as myself. Looks like my problem was print statements. I deleted the single one I had and it started working again.
Reply all
Reply to author
Forward
0 new messages