invertase / dart_custom_lint

💡 Easily write powerful Dart & Flutter lint rules for your projects or for users of your packages.
https://pub.dev/packages/custom_lint
Apache License 2.0
283 stars 63 forks source link

Dart Analysis Server always crashes whenever I launch my custom lint project on vs code #60

Closed biplab-khalti closed 1 year ago

biplab-khalti commented 1 year ago

Describe the bug Dart Analysis Server always crashes whenever I launch my custom lint project on vs code. The crash doesn't take place when I launch my other flutter projects.

flutter doctor -v ``` [✓] Flutter (Channel stable, 3.3.10, on Fedora Linux 37 (Workstation Edition) 6.0.17-300.fc37.x86_64, locale en_US.UTF-8) • Flutter version 3.3.10 on channel stable at /home/biplab-khalti/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 135454af32 (3 weeks ago), 2022-12-15 07:36:55 -0800 • Engine revision 3316dd8728 • Dart version 2.18.6 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/biplab-khalti/Android/Sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /var/lib/snapd/snap/android-studio/125/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at google-chrome [✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1 [✓] Android Studio (version 2021.3) • Android Studio at /var/lib/snapd/snap/android-studio/125/android-studio • Flutter plugin version 71.0.3 • Dart plugin version 213.7433 • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) [✓] VS Code (version 1.74.2) • VS Code at /usr/share/code • Flutter extension version 3.56.0 [✓] Connected device (2 available) • Linux (desktop) • linux • linux-x64 • Fedora Linux 37 (Workstation Edition) 6.0.17-300.fc37.x86_64 • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```

Screenshot from 2023-01-08 22-32-09

rrousselGit commented 1 year ago

Could you share your custom_lint.log file, if any?

biplab-khalti commented 1 year ago

Sorry. The log file is not there.

rrousselGit commented 1 year ago

Any chance you could create a git repo for reproducing the issue?

biplab-khalti commented 1 year ago

Okay. So, I had a folder Experiments where I created 2 dart packages - one for the lint and other just a dummy project to check if the lint is working. If I launched my Experiments directory on vs code, that is when I get the analysis server issue. On launching just the lint project separately on vs code, the analyzer seems to be working fine.

rrousselGit commented 1 year ago

Sure but I'd need something I can run. It's unlikely to be something I can debug with just a description of your situation

biplab-khalti commented 1 year ago

Alright. let me create a git repo.

kuhnroyal commented 1 year ago

Seeing these crashes as well on 0.1.0 And also timeouts of dart run custom_lint with certain analyzer and _fe_analyzer_shared versions combinations.

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
Bad state: Two ContextRoots depend on _fe_analyzer_shared but use different version,
therefore custom_lint does not know which one to pick.
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-50.0.0/
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-52.0.0/

at:
#0      _writePackageConfigForTempProject (package:custom_lint/src/v2/server_to_client_channel.dart:74:9)
#1      _SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:225:5)
#2      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:269:25)
<asynchronous suspension>
#3      CustomLintServer._handleAnalysisSetContextRoots (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:244:5)
<asynchronous suspension>
#4      CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:118:22)
<asynchronous suspension>

[custom_lint] 2023-01-08T16:59:29.638686 Bad state: No element
[custom_lint] 2023-01-08T16:59:29.638686 #0      Stream.first.<anonymous closure> (dart:async/stream.dart:1581:9)
[custom_lint] 2023-01-08T16:59:29.638686 #1      _rootRun (dart:async/zone.dart:1383:47)
[custom_lint] 2023-01-08T16:59:29.638686 #2      _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T16:59:29.638686 #3      _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T16:59:29.638686 #4      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T16:59:29.638686 #5      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T16:59:29.638686 #6      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T16:59:29.638686 #7      _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
[custom_lint] 2023-01-08T16:59:29.638686 #8      _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
[custom_lint] 2023-01-08T16:59:29.638686 #9      _rootRun (dart:async/zone.dart:1391:13)
[custom_lint] 2023-01-08T16:59:29.638686 #10     _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T16:59:29.638686 #11     _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T16:59:29.638686 #12     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T16:59:29.638686 #13     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T16:59:29.638686 #14     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T16:59:29.638686 #15     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
[custom_lint] 2023-01-08T16:59:29.638686 #16     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
[custom_lint] 2023-01-08T16:59:29.638686 #17     _StreamController.close (dart:async/stream_controller.dart:630:5)
[custom_lint] 2023-01-08T16:59:29.638686 #18     _RawServerSocket.listen.<anonymous closure> (dart:io-patch/socket_patch.dart:1762:37)
[custom_lint] 2023-01-08T16:59:29.638686 #19     _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1401:39)
[custom_lint] 2023-01-08T16:59:29.638686 #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
[custom_lint] 2023-01-08T16:59:29.638686
The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
Bad state: Two ContextRoots depend on _fe_analyzer_shared but use different version,
therefore custom_lint does not know which one to pick.
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-50.0.0/
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-49.0.0/

at:
#0      _writePackageConfigForTempProject (package:custom_lint/src/v2/server_to_client_channel.dart:74:9)
#1      _SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:225:5)
#2      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:269:25)
<asynchronous suspension>
#3      CustomLintServer._handleAnalysisSetContextRoots (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:244:5)
<asynchronous suspension>
#4      CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:118:22)
<asynchronous suspension>

[custom_lint] 2023-01-08T17:03:48.381953 Bad state: No element
[custom_lint] 2023-01-08T17:03:48.381953 #0      Stream.first.<anonymous closure> (dart:async/stream.dart:1581:9)
[custom_lint] 2023-01-08T17:03:48.381953 #1      _rootRun (dart:async/zone.dart:1383:47)
[custom_lint] 2023-01-08T17:03:48.381953 #2      _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:03:48.381953 #3      _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:03:48.381953 #4      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:03:48.381953 #5      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:03:48.381953 #6      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:03:48.381953 #7      _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
[custom_lint] 2023-01-08T17:03:48.381953 #8      _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
[custom_lint] 2023-01-08T17:03:48.381953 #9      _rootRun (dart:async/zone.dart:1391:13)
[custom_lint] 2023-01-08T17:03:48.381953 #10     _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:03:48.381953 #11     _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:03:48.381953 #12     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:03:48.381953 #13     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:03:48.381953 #14     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:03:48.381953 #15     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
[custom_lint] 2023-01-08T17:03:48.381953 #16     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
[custom_lint] 2023-01-08T17:03:48.381953 #17     _StreamController.close (dart:async/stream_controller.dart:630:5)
[custom_lint] 2023-01-08T17:03:48.381953 #18     _RawServerSocket.listen.<anonymous closure> (dart:io-patch/socket_patch.dart:1762:37)
[custom_lint] 2023-01-08T17:03:48.381953 #19     _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1401:39)
[custom_lint] 2023-01-08T17:03:48.381953 #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
[custom_lint] 2023-01-08T17:03:48.381953
The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
Bad state: Two ContextRoots depend on _fe_analyzer_shared but use different version,
therefore custom_lint does not know which one to pick.
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-50.0.0/
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-51.0.0/

at:
#0      _writePackageConfigForTempProject (package:custom_lint/src/v2/server_to_client_channel.dart:74:9)
#1      _SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:225:5)
#2      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:269:25)
<asynchronous suspension>
#3      CustomLintServer._handleAnalysisSetContextRoots (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:244:5)
<asynchronous suspension>
#4      CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:118:22)
<asynchronous suspension>

[custom_lint] 2023-01-08T17:17:33.009881 Bad state: No element
[custom_lint] 2023-01-08T17:17:33.009881 #0      Stream.first.<anonymous closure> (dart:async/stream.dart:1581:9)
[custom_lint] 2023-01-08T17:17:33.009881 #1      _rootRun (dart:async/zone.dart:1383:47)
[custom_lint] 2023-01-08T17:17:33.009881 #2      _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:17:33.009881 #3      _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:17:33.009881 #4      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:17:33.009881 #5      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:17:33.009881 #6      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:17:33.009881 #7      _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
[custom_lint] 2023-01-08T17:17:33.009881 #8      _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
[custom_lint] 2023-01-08T17:17:33.009881 #9      _rootRun (dart:async/zone.dart:1391:13)
[custom_lint] 2023-01-08T17:17:33.009881 #10     _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:17:33.009881 #11     _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:17:33.009881 #12     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:17:33.009881 #13     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:17:33.009881 #14     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:17:33.009881 #15     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
[custom_lint] 2023-01-08T17:17:33.009881 #16     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
[custom_lint] 2023-01-08T17:17:33.009881 #17     _StreamController.close (dart:async/stream_controller.dart:630:5)
[custom_lint] 2023-01-08T17:17:33.009881 #18     _RawServerSocket.listen.<anonymous closure> (dart:io-patch/socket_patch.dart:1762:37)
[custom_lint] 2023-01-08T17:17:33.009881 #19     _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1401:39)
[custom_lint] 2023-01-08T17:17:33.009881 #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
[custom_lint] 2023-01-08T17:17:33.009881
The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
Bad state: Two ContextRoots depend on collection but use different version,
therefore custom_lint does not know which one to pick.
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/collection-1.16.0/
- file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/collection-1.17.0/

at:
#0      _writePackageConfigForTempProject (package:custom_lint/src/v2/server_to_client_channel.dart:74:9)
#1      _SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:225:5)
#2      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:269:25)
<asynchronous suspension>
#3      CustomLintServer._handleAnalysisSetContextRoots (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:244:5)
<asynchronous suspension>
#4      CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:118:22)
<asynchronous suspension>

[custom_lint] 2023-01-08T17:19:48.552099 Bad state: No element
[custom_lint] 2023-01-08T17:19:48.552099 #0      Stream.first.<anonymous closure> (dart:async/stream.dart:1581:9)
[custom_lint] 2023-01-08T17:19:48.552099 #1      _rootRun (dart:async/zone.dart:1383:47)
[custom_lint] 2023-01-08T17:19:48.552099 #2      _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:19:48.552099 #3      _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:19:48.552099 #4      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:19:48.552099 #5      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:19:48.552099 #6      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:19:48.552099 #7      _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
[custom_lint] 2023-01-08T17:19:48.552099 #8      _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
[custom_lint] 2023-01-08T17:19:48.552099 #9      _rootRun (dart:async/zone.dart:1391:13)
[custom_lint] 2023-01-08T17:19:48.552099 #10     _CustomZone.run (dart:async/zone.dart:1293:19)
[custom_lint] 2023-01-08T17:19:48.552099 #11     _CustomZone.runGuarded (dart:async/zone.dart:1201:7)
[custom_lint] 2023-01-08T17:19:48.552099 #12     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
[custom_lint] 2023-01-08T17:19:48.552099 #13     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
[custom_lint] 2023-01-08T17:19:48.552099 #14     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
[custom_lint] 2023-01-08T17:19:48.552099 #15     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
[custom_lint] 2023-01-08T17:19:48.552099 #16     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
[custom_lint] 2023-01-08T17:19:48.552099 #17     _StreamController.close (dart:async/stream_controller.dart:630:5)
[custom_lint] 2023-01-08T17:19:48.552099 #18     _RawServerSocket.listen.<anonymous closure> (dart:io-patch/socket_patch.dart:1762:37)
[custom_lint] 2023-01-08T17:19:48.552099 #19     _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1401:39)
[custom_lint] 2023-01-08T17:19:48.552099 #20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
[custom_lint] 2023-01-08T17:19:48.552099
[custom_lint] 2023-01-08T18:22:00.174957 FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
[custom_lint] 2023-01-08T18:22:00.174957 #0      _RandomAccessFile.writeFromSync (dart:io/file_impl.dart:873:7)
[custom_lint] 2023-01-08T18:22:00.174957 #1      _StdConsumer.addStream.<anonymous closure> (dart:io/stdio.dart:309:15)
[custom_lint] 2023-01-08T18:22:00.174957 #2      _rootRunUnary (dart:async/zone.dart:1399:47)
[custom_lint] 2023-01-08T18:22:00.174957 #3      _CustomZone.runUnary (dart:async/zone.dart:1300:19)
[custom_lint] 2023-01-08T18:22:00.174957 #4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
[custom_lint] 2023-01-08T18:22:00.174957 #5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
[custom_lint] 2023-01-08T18:22:00.174957 #6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
[custom_lint] 2023-01-08T18:22:00.174957 #7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
[custom_lint] 2023-01-08T18:22:00.174957 #8      _StreamController._add (dart:async/stream_controller.dart:648:7)
[custom_lint] 2023-01-08T18:22:00.174957 #9      _StreamController.add (dart:async/stream_controller.dart:596:5)
[custom_lint] 2023-01-08T18:22:00.174957 #10     _StreamSinkImpl.add (dart:io/io_sink.dart:136:17)
[custom_lint] 2023-01-08T18:22:00.174957 #11     _IOSinkImpl.write (dart:io/io_sink.dart:269:5)
[custom_lint] 2023-01-08T18:22:00.174957 #12     _IOSinkImpl.writeln (dart:io/io_sink.dart:289:5)
[custom_lint] 2023-01-08T18:22:00.174957 #13     _StdSink.writeln (dart:io/stdio.dart:342:11)
[custom_lint] 2023-01-08T18:22:00.174957 #14     _runPlugins (package:custom_lint/custom_lint.dart:84:12)
[custom_lint] 2023-01-08T18:22:00.174957 <asynchronous suspension>
[custom_lint] 2023-01-08T18:22:00.174957 #15     customLint.<anonymous closure> (package:custom_lint/custom_lint.dart:52:7)
[custom_lint] 2023-01-08T18:22:00.174957 <asynchronous suspension>
[custom_lint] 2023-01-08T18:22:00.174957 #16     customLint (package:custom_lint/custom_lint.dart:49:3)
[custom_lint] 2023-01-08T18:22:00.174957 <asynchronous suspension>
[custom_lint] 2023-01-08T18:22:00.174957 #17     entrypoint (file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/custom_lint-0.1.0/bin/custom_lint.dart:31:3)
[custom_lint] 2023-01-08T18:22:00.174957 <asynchronous suspension>
[custom_lint] 2023-01-08T18:22:00.174957 #18     main (file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/custom_lint-0.1.0/bin/custom_lint.dart:35:3)
[custom_lint] 2023-01-08T18:22:00.174957 <asynchronous suspension>
[custom_lint] 2023-01-08T18:22:00.174957
[custom_lint] 2023-01-08T18:55:04.887674 FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
[custom_lint] 2023-01-08T18:55:04.887674 #0      _RandomAccessFile.writeFromSync (dart:io/file_impl.dart:873:7)
[custom_lint] 2023-01-08T18:55:04.887674 #1      _StdConsumer.addStream.<anonymous closure> (dart:io/stdio.dart:309:15)
[custom_lint] 2023-01-08T18:55:04.887674 #2      _rootRunUnary (dart:async/zone.dart:1399:47)
[custom_lint] 2023-01-08T18:55:04.887674 #3      _CustomZone.runUnary (dart:async/zone.dart:1300:19)
[custom_lint] 2023-01-08T18:55:04.887674 #4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
[custom_lint] 2023-01-08T18:55:04.887674 #5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
[custom_lint] 2023-01-08T18:55:04.887674 #6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
[custom_lint] 2023-01-08T18:55:04.887674 #7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
[custom_lint] 2023-01-08T18:55:04.887674 #8      _StreamController._add (dart:async/stream_controller.dart:648:7)
[custom_lint] 2023-01-08T18:55:04.887674 #9      _StreamController.add (dart:async/stream_controller.dart:596:5)
[custom_lint] 2023-01-08T18:55:04.887674 #10     _StreamSinkImpl.add (dart:io/io_sink.dart:136:17)
[custom_lint] 2023-01-08T18:55:04.887674 #11     _IOSinkImpl.write (dart:io/io_sink.dart:269:5)
[custom_lint] 2023-01-08T18:55:04.887674 #12     _IOSinkImpl.writeln (dart:io/io_sink.dart:289:5)
[custom_lint] 2023-01-08T18:55:04.887674 #13     _StdSink.writeln (dart:io/stdio.dart:342:11)
[custom_lint] 2023-01-08T18:55:04.887674 #14     _runPlugins (package:custom_lint/custom_lint.dart:84:12)
[custom_lint] 2023-01-08T18:55:04.887674 <asynchronous suspension>
[custom_lint] 2023-01-08T18:55:04.887674 #15     customLint.<anonymous closure> (package:custom_lint/custom_lint.dart:52:7)
[custom_lint] 2023-01-08T18:55:04.887674 <asynchronous suspension>
[custom_lint] 2023-01-08T18:55:04.887674 #16     customLint (package:custom_lint/custom_lint.dart:49:3)
[custom_lint] 2023-01-08T18:55:04.887674 <asynchronous suspension>
[custom_lint] 2023-01-08T18:55:04.887674 #17     entrypoint (file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/custom_lint-0.1.0/bin/custom_lint.dart:31:3)
[custom_lint] 2023-01-08T18:55:04.887674 <asynchronous suspension>
[custom_lint] 2023-01-08T18:55:04.887674 #18     main (file:///Users/USER/.pub-cache/hosted/pub.dartlang.org/custom_lint-0.1.0/bin/custom_lint.dart:35:3)
[custom_lint] 2023-01-08T18:55:04.887674 <asynchronous suspension>
[custom_lint] 2023-01-08T18:55:04.887674

After playing around with the versions, I seem to only be able to run anything with analyzer: 5.2.0 and _fe_analyzer_shared: 50.0.0.

Biplab-Dutta commented 1 year ago

Hey @rrousselGit. Sorry for the late response. Replying from my main github account. haha Here's a git repo. https://github.com/Biplab-Dutta/custom_lint_issue_demo

kuhnroyal commented 1 year ago

I have the exact same project setup, an example project with test cases.

Biplab-Dutta commented 1 year ago

Hi @kuhnroyal. Can you check something for me? Try launching the lint package's code separately on your IDE and see if the analyzer works.

kuhnroyal commented 1 year ago

Hi @kuhnroyal. Can you check something for me? Try launching the lint package's code separately on your IDE and see if the analyzer works.

Yea seems to work.

rrousselGit commented 1 year ago

@kuhnroyal You have two projects or more in your repository that use different dependency versions.
For custom_lint to work, all projects opened where custom_lint is enabled must use the same dependency versions.

I'll see how I can make the error more obvious, but in any case, you need to fix this on your side.

rrousselGit commented 1 year ago

@Biplab-Dutta Your custom_lint setup is incorrect.

It's weird that the analyzer crashes, but you shouldn't have a bin folder. There was a breaking change recently on how plugins are created. See the readme/changelog

Biplab-Dutta commented 1 year ago

Should have checked the CHANGELOG 🤦‍♂️.

Biplab-Dutta commented 1 year ago

@rrousselGit looks like the README has not been updated. image

rrousselGit commented 1 year ago

Eh I updated the code snippet but forgot to change the path. Will fix

Biplab-Dutta commented 1 year ago

I shall try again tomorrow following the new instructions as shown in the CHANGELOG. Shall let you know if anything goes wrong. Thanks. It's almost 1 am 🥶

Biplab-Dutta commented 1 year ago

So, I gave it a last go before going to bed. @rrousselGit would you mind checking if I am doing something wrong again? The analysis server still crashes after editing the entry points. https://github.com/Biplab-Dutta/custom_lint_issue_demo

rrousselGit commented 1 year ago

@Biplab-Dutta You didn't implement the getLints() method, so there's a compilation error.

Afaik the server crashes because it fails to report the error about how your plugin failed to start, so it makes debugging a bit difficult.

Biplab-Dutta commented 1 year ago

Let's not close this issue for now. I will come back to it tomorrow again.

kuhnroyal commented 1 year ago

@kuhnroyal You have two projects or more in your repository that use different dependency versions. For custom_lint to work, all projects opened where custom_lint is enabled must use the same dependency versions.

I'll see how I can make the error more obvious, but in any case, you need to fix this on your side.

Yea I figured and after freezing some deps my test project (example folder inside my lints project) has the expected lints when running dart run custom_lint example. But the analysis server in IntelliJ is still crashing.

rrousselGit commented 1 year ago

@kuhnroyal it'd be great if you could share some way to reproduce your issue

marcotrumpet commented 1 year ago

I all, I'm having the same issue.. not sure if I did something wrong.. if it can help here is my repo: https://github.com/marcotrumpet/my_custom_lints/tree/bugfix/dart-analysis-server-error Inside it, there is a package called 'mason_custom_lints' and inside 'my_dart_app' the implementation. I used it with the past implementation but I have had issues since trying to update to version 0.1.0.

Please ask if you want more specifications I'll continue to inspect this.

Thanks!

EDIT with flutter doctor:

[✓] Flutter (Channel stable, 3.3.5, on macOS 13.0.1 22A400 darwin-arm, locale it-IT)
    • Flutter version 3.3.5 on channel stable at /Users/marcogaletta/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9111f6402 (3 months ago), 2022-10-19 12:27:13 -0700
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/marcogaletta/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
rrousselGit commented 1 year ago

It could be based on your SDK version too. Do you have the issue with the stable channel and master channel?

rrousselGit commented 1 year ago

But my bet is that there's something that doesn't compile in your plugin, which prevents the plugin from starting.

marcotrumpet commented 1 year ago

Hey, thanks for your fast response. I'll check with other flutter versions. Before the upgrade btw I had an error from vscode about the error starting the plugin (if there was an error).

rrousselGit commented 1 year ago

I've cloned your project and it doesn't crash for me. And it highlights one compilation error:

The available unit doesn't exists

Screenshot 2023-01-09 at 16 26 13

rrousselGit commented 1 year ago

Fixed the error and it seems to be working fine for me

Screenshot 2023-01-09 at 16 27 24

marcotrumpet commented 1 year ago

you're too fast :D just fixed that.. also upgraded to flutter 3.3.10 but same error.. wonder if a reboot will solve as always

rrousselGit commented 1 year ago

Make sure to restart everything and run pub upgrade everywhere

marcotrumpet commented 1 year ago

Still having issues. I also try to use the package on my work laptop (different mac machine) and the analysis server crashed on it too

rrousselGit commented 1 year ago

Dang it Try disabling custom_lint from your analysis_options.yaml and see if there's no error in your plugin

Obviously you won't see lints, but your analyzer server shouldn't crash anymore. So errors should pop up if any

rrousselGit commented 1 year ago

Also, check if the custom_lint command works and correctly outputs your lint.

Biplab-Dutta commented 1 year ago

About the server crashing, I tried launching the projects on 2 different machines and it crashed on both of them. I had a directory opened in Vs code which had 2 packages, one for the lint and other just a dummy sample package to test the lint. Also, tried with the updated entry points and all.. Like I said yesterday, the analyzer wouldn't crash if I opened the lint project separately in VS code. But with the directory opened in Vs code that contained a lint package and a dummy sample package, it crashed everytime. Also, such crashes never used to happen earlier.. this is the 1st time I am experiencing something like that.

marcotrumpet commented 1 year ago

So, disabling custom_lint seems to let server analysis alive and working. But running dart run custom_lint gives Building package executable... (3.3s) Built custom_lint:custom_lint. some_bloc.dart:1:7 • If the file name ends with _bloc the className must end with Bloc • class_name_should_match_file_name So it seems something related to vscode probably? notice that it doesn't create a log file since the error

rrousselGit commented 1 year ago

So it works when using the CLI eh. Do you mind modifying the source of custom_lint to add a log?

Go in the file: custom_lint/lib/src/v2/server_to_client_channel.dart

Inside _SocketCustomLintServerToClientChannel.init on line 266 add the following:

    final processFuture = _asyncRetry(retryCount: 5, () async {
      port = await _findPossiblyUnusedPort();
      final process = await Process.start(
        Platform.resolvedExecutable,
        [
          '--enable-vm-service=$port',
          join('lib', 'main.dart'),
          await _serverSocket.then((value) => value.port.toString())
        ],
        workingDirectory: _tempDirectory.path,
      );
      return process;
    });

+    void log(Object message) {
+      for (final root in _contextRoots.roots) {
+        final file = File(join(root.root, 'log.txt'));
+        file.writeAsString('$message\n', mode: FileMode.append);
+      }
+    }
+
+    log('Here');
+    processFuture.then(
+      (_) => log('Started successfully'),
+      onError: (err, stack) {
+        log('Error: $err\n$stack');
+      },
+    );

    await processFuture.then(
      _process.complete,
      onError: _process.completeError,
    );

Restarting the project should create a log.txt somewhere in your project.

kuhnroyal commented 1 year ago

Yea same for me, running in CLI works and outputs the expected lints but constant crashing in IntelliJ. I now published our custom lints package to our private registry and use it in our app, just to get rid of local path dependencies but it still crashes.

kuhnroyal commented 1 year ago
Here
Started successfully

But keeps crashing

rrousselGit commented 1 year ago

Funky. At least it shows the problem isn't here.

I'll try some things and make a dev release. I have some theories. I'll come back to you tomorrow so that you can try it out and see if it fixes the problem.

kuhnroyal commented 1 year ago

Found something.

When running flutter analyze without the plugin enabled, it just works normal. With the plugin enabled, Flutter crashes:

Flutter crash report.
Please report a bug at https://github.com/flutter/flutter/issues.

## command

flutter analyze

## exception

_Exception: Exception: analysis server exited with code -6 and output:
[stdout] {"event":"analysis.errors","params":{"file":"/Users/USER/workspace/PROJECT/test/unit/util/pattern_validator_test.dart","errors":[]}}
[stdout] {"event":"analysis.errors","params":{"file":"/Users/USER/workspace/PROJECT/test/unit/util/number_format_test.dart","errors":[]}}
[stderr] ../../runtime/vm/message_snapshot.cc: 576: error: expected: !lib.IsNull()
[stderr] version=2.18.5 (stable) (Tue Nov 22 15:47:29 2022 +0000) on "macos_x64"
[stderr] pid=76493, thread=9991, isolate_group=main(0x7f9f2c872800), isolate=main(0x7f9f2c898200)
[stderr] isolate_instructions=106e7e4c0, vm_instructions=106e7e4c0
[stderr]   pc 0x00000001070e6af4 fp 0x000070000ee31580 dart::Profiler::DumpStackTrace(void*)+0x64
[stderr]   pc 0x0000000106e7e694 fp 0x000070000ee31660 dart::Assert::Fail(char const*, ...) const+0x84
[stderr]   pc 0x000000010704d425 fp 0x000070000ee316c0 dart::ReadApiMessage(dart::Zone*, dart::Message*)+0x8ff5
[stderr]   pc 0x0000000107043494 fp 0x000070000ee31720 dart::MessageDeserializer::Deserialize()+0x234
[stderr]   pc 0x00000001070443e9 fp 0x000070000ee31850 dart::ReadMessage(dart::Thread*, dart::Message*)+0x159
[stderr]   pc 0x000000010701315f fp 0x000070000ee31df0 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message> >)+0xbf
[stderr]   pc 0x000000010703ed8d fp 0x000070000ee31e60 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x12d
[stderr]   pc 0x000000010703f49f fp 0x000070000ee31eb0 dart::MessageHandler::TaskCallback()+0x1df
[stderr]   pc 0x0000000107177bf7 fp 0x000070000ee31f30 dart::ThreadPool::WorkerLoop(dart::ThreadPool::Worker*)+0x147
[stderr]   pc 0x000000010717805e fp 0x000070000ee31f60 dart::ThreadPool::Worker::Main(unsigned long)+0x6e
[stderr]   pc 0x00000001070e28df fp 0x000070000ee31fb0 dart::OSThread::GetMaxStackSize()+0xaf
[stderr]   pc 0x00007ff8144b5259 fp 0x000070000ee31fd0 _pthread_start+0x7d
[stderr]   pc 0x00007ff8144b0c7b fp 0x000070000ee31ff0 thread_start+0xf
[stderr] -- End of DumpStackTrace

## flutter doctor

[✓] Flutter (Channel stable, 3.3.9, on macOS 13.1 22C65 darwin-x64, locale de-DE)
    • Flutter version 3.3.9 on channel stable at /Users/USER/fvm/versions/3.3.9@stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (vor 7 Wochen), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0
    • Pub download mirror https://pub

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/USER/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/USER/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/USER/Library/Android/sdk
    • Java binary at: /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.1)
    • IntelliJ at /Users/USER/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 71.3.6
    • Dart plugin version 223.8214.16

[✓] VS Code (version 1.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
rrousselGit commented 1 year ago

Yeah that's an analyzer bug. It was fixed

In theory if you switch to the master channel, the crash will disappear

marcotrumpet commented 1 year ago

To me is crashing also when I clone the repo to add log.. the thing is why it's working for you with the same code 😨I even tested the 0.1.1 version but still the same

rrousselGit commented 1 year ago

You mean cloning custom_lint causes a crash too? eh

marcotrumpet commented 1 year ago

yep, cloning this whole repo and opening with vscode give me a crash.. double check this is not my mac problem by opening other repo (and closing every other one)..

kuhnroyal commented 1 year ago

You mean cloning custom_lint causes a crash too? eh

The plugins for both example projects fail to start for me. Running dart test fails with a lot of errors.

rrousselGit commented 1 year ago

What error?

rrousselGit commented 1 year ago

I've published version 0.1.2-dev in an attempt to fix this. Give it a go and tell me if there's any improvement

Make sure to look at the custom_lint.log file to see if there's any error in it too.

Biplab-Dutta commented 1 year ago

Shall give it a try tonight..

kuhnroyal commented 1 year ago

It keeps crashing, there is no custom_lint.log being created. I enabled the Analysis Server logging, these are the last statements before the crash:

1673351366963:PluginReq:{"id"::"0","method"::"plugin.versionCheck","params"::{"byteStorePath"::"/Users/USER/.dartServer/.analysis-driver","sdkPath"::"/Users/USER/fvm/versions/3.3.9@stable/bin/cache/dart-sdk","version"::"1.0.0-alpha.0"}}:file::///Users/USER/.dartServer/.plugin_manager/ac7608e312002641015034095a33ca07/analyzer_plugin/bin/plugin.dart::
1673351366993:PluginRes:{"id"::"0","requestTime"::1673351366969,"result"::{"isCompatible"::true,"name"::"custom_lint","version"::"1.0.0-alpha.0","contactInfo"::"https:://github.com/invertase/dart_custom_lint/issues","interestingFiles"::["*.dart"]}}:file::///Users/USER/.dartServer/.plugin_manager/ac7608e312002641015034095a33ca07/analyzer_plugin/bin/plugin.dart::
rrousselGit commented 1 year ago

There's nothing of value in those logs sadly