Open incendial opened 1 year ago
I've also noticed several other errors in the console:
[Error - 12:20:27] An error occurred while handling textDocument/codeAction request: RangeError (index): Index out of range: index should be less than 1: 1
#0 Uint32List.[] (dart:typed_data-patch/typed_data_patch.dart:2594:7)
#1 LibraryReader._readClassElement (package:analyzer/src/summary2/bundle_reader.dart:617:45)
#2 LibraryReader._readClasses.<anonymous closure> (package:analyzer/src/summary2/bundle_reader.dart:646:14)
#3 new _GrowableList.generate (dart:core-patch/growable_array.dart:136:28)
#4 LibraryReader._readClasses (package:analyzer/src/summary2/bundle_reader.dart:645:32)
#5 LibraryReader._readUnitElement (package:analyzer/src/summary2/bundle_reader.dart:1487:5)
#6 LibraryReader.readElement (package:analyzer/src/summary2/bundle_reader.dart:509:46)
#7 LinkedElementFactory.createLibraryElementForReading (package:analyzer/src/summary2/linked_element_factory.dart:125:33)
#8 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:180:14)
#9 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:184:25)
#10 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:184:25)
#11 LinkedElementFactory.buildExportNamespace (package:analyzer/src/summary2/linked_element_factory.dart:90:21)
#12 LibraryElementImpl.exportNamespace (package:analyzer/src/dart/element/element.dart:3972:42)
#13 LibraryElementExtensions.exportedExtensions (package:analysis_server/src/utilities/extensions/element.dart:61:12)
#14 _ImportLibraryContainingExtension.compute (package:analysis_server/src/services/correction/dart/import_library.dart:452:42)
#15 FixProcessor._addFromProducers.compute (package:analysis_server/src/services/correction/fix_internal.dart:1588:24)
#16 FixProcessor._addFromProducers (package:analysis_server/src/services/correction/fix_internal.dart:1614:19)
<asynchronous suspension>
#17 FixProcessor.compute (package:analysis_server/src/services/correction/fix_internal.dart:1543:5)
<asynchronous suspension>
#18 DartFixContributor.computeFixes (package:analysis_server/src/services/correction/fix_internal.dart:235:19)
<asynchronous suspension>
#19 DartCodeActionsProducer.getFixActions (package:analysis_server/src/lsp/handlers/code_actions/dart.dart:154:23)
<asynchronous suspension>
#20 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#21 CodeActionHandler.handle (package:analysis_server/src/lsp/handlers/handler_code_actions.dart:202:16)
<asynchronous suspension>
#22 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:271:22)
<asynchronous suspension>
#23 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:849:20)
<asynchronous suspension>
#24 LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:386:15)
<asynchronous suspension>
#25 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#26 LspAnalysisServer.handleMessage.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:370:11)
<asynchronous suspension>
[Error - 12:20:28] An error occurred while handling textDocument/codeAction request: type 'Null' is not a subtype of type 'LibraryOrAugmentationElement' in type cast
#0 CompilationUnitElementImpl.enclosingElement (package:analyzer/src/dart/element/element.dart:1166:30)
#1 ElementImpl.thisOrAncestorOfType (package:analyzer/src/dart/element/element.dart:2736:27)
#2 _HasLibraryMixin.library (package:analyzer/src/dart/element/element.dart:6571:37)
#3 AnalysisDriver.getLibraryByUri.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:767:62)
<asynchronous suspension>
#4 TopLevelDeclarations.withName (package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart:42:27)
<asynchronous suspension>
#5 ImportLibrary._importLibraryForElement (package:analysis_server/src/services/correction/dart/import_library.dart:289:33)
<asynchronous suspension>
#6 ImportLibrary.producers (package:analysis_server/src/services/correction/dart/import_library.dart:60:9)
<asynchronous suspension>
#7 FixProcessor._addFromProducers (package:analysis_server/src/services/correction/fix_internal.dart:1613:32)
<asynchronous suspension>
#8 FixProcessor.compute (package:analysis_server/src/services/correction/fix_internal.dart:1543:5)
<asynchronous suspension>
#9 DartFixContributor.computeFixes (package:analysis_server/src/services/correction/fix_internal.dart:235:19)
<asynchronous suspension>
#10 DartCodeActionsProducer.getFixActions (package:analysis_server/src/lsp/handlers/code_actions/dart.dart:154:23)
<asynchronous suspension>
#11 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#12 CodeActionHandler.handle (package:analysis_server/src/lsp/handlers/handler_code_actions.dart:202:16)
<asynchronous suspension>
#13 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:271:22)
<asynchronous suspension>
#14 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:849:20)
<asynchronous suspension>
#15 LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:386:15)
<asynchronous suspension>
#16 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#17 LspAnalysisServer.handleMessage.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:370:11)
<asynchronous suspension>
[Error - 12:20:41] An error occurred while handling textDocument/codeAction request: Invalid argument(s): Missing library: package:dcm_analyzer/src/analyzers/unused_files_analyzer/unused_files_analyzer.dart
... here goes a list of all libraries ...
#0 LinkedElementFactory.createLibraryElementForReading (package:analyzer/src/summary2/linked_element_factory.dart:116:7)
#1 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:180:14)
#2 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:184:25)
#3 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:184:25)
#4 LinkedElementFactory.buildExportNamespace (package:analyzer/src/summary2/linked_element_factory.dart:90:21)
#5 LibraryElementImpl.exportNamespace (package:analyzer/src/dart/element/element.dart:3972:42)
#6 LibraryElementExtensions.exportedExtensions (package:analysis_server/src/utilities/extensions/element.dart:61:12)
#7 _ImportLibraryContainingExtension.compute (package:analysis_server/src/services/correction/dart/import_library.dart:452:42)
#8 FixProcessor._addFromProducers.compute (package:analysis_server/src/services/correction/fix_internal.dart:1588:24)
#9 FixProcessor._addFromProducers (package:analysis_server/src/services/correction/fix_internal.dart:1614:19)
<asynchronous suspension>
#10 FixProcessor.compute (package:analysis_server/src/services/correction/fix_internal.dart:1543:5)
<asynchronous suspension>
#11 DartFixContributor.computeFixes (package:analysis_server/src/services/correction/fix_internal.dart:235:19)
<asynchronous suspension>
#12 DartCodeActionsProducer.getFixActions (package:analysis_server/src/lsp/handlers/code_actions/dart.dart:154:23)
<asynchronous suspension>
#13 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#14 CodeActionHandler.handle (package:analysis_server/src/lsp/handlers/handler_code_actions.dart:202:16)
<asynchronous suspension>
#15 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:271:22)
<asynchronous suspension>
#16 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:849:20)
<asynchronous suspension>
#17 LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:386:15)
<asynchronous suspension>
#18 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#19 LspAnalysisServer.handleMessage.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:370:11)
<asynchronous suspension>
[Error - 12:44:20] An error occurred while handling textDocument/codeAction request: Bad state: Expected existing element: root::package:dcm_analyzer/src/analyzers/lint_analyzer/lint_analysis_config.dart::@unit::package:dcm_analyzer/src/analyzers/lint_analyzer/lint_analysis_config.dart
#0 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:195:7)
#1 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:184:25)
#2 LinkedElementFactory.buildExportNamespace (package:analyzer/src/summary2/linked_element_factory.dart:90:21)
#3 LibraryElementImpl.exportNamespace (package:analyzer/src/dart/element/element.dart:3972:42)
#4 LibraryElementExtensions.exportedExtensions (package:analysis_server/src/utilities/extensions/element.dart:61:12)
#5 _ImportLibraryContainingExtension.compute (package:analysis_server/src/services/correction/dart/import_library.dart:452:42)
#6 FixProcessor._addFromProducers.compute (package:analysis_server/src/services/correction/fix_internal.dart:1588:24)
#7 FixProcessor._addFromProducers (package:analysis_server/src/services/correction/fix_internal.dart:1614:19)
<asynchronous suspension>
#8 FixProcessor.compute (package:analysis_server/src/services/correction/fix_internal.dart:1543:5)
<asynchronous suspension>
#9 DartFixContributor.computeFixes (package:analysis_server/src/services/correction/fix_internal.dart:235:19)
<asynchronous suspension>
#10 DartCodeActionsProducer.getFixActions (package:analysis_server/src/lsp/handlers/code_actions/dart.dart:154:23)
<asynchronous suspension>
#11 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#12 CodeActionHandler.handle (package:analysis_server/src/lsp/handlers/handler_code_actions.dart:202:16)
<asynchronous suspension>
#13 ServerStateMessageHandler.handleMessage (package:analysis_server/src/lsp/handlers/handlers.dart:271:22)
<asynchronous suspension>
#14 LspAnalysisServer._handleRequestMessage (package:analysis_server/src/lsp/lsp_analysis_server.dart:849:20)
<asynchronous suspension>
#15 LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:386:15)
<asynchronous suspension>
#16 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:164:18)
<asynchronous suspension>
#17 LspAnalysisServer.handleMessage.<anonymous closure> (package:analysis_server/src/lsp/lsp_analysis_server.dart:370:11)
<asynchronous suspension>
but I have no steps. Will monitor the console for some time to see if they appear again.
Thanks for all of the stack traces!!
I created a test for the first case (https://dart-review.googlesource.com/c/sdk/+/291340), but it fails to reproduce a problem. If you could try the simplified version and let me know whether it crashes for you, that would be great. Otherwise I'll assume that the bug has already been fixed.
If you can create a scenario to reproduce LibraryReader._readClassElement
exception, this would be a big help.
We see it also internally, since about September 2022, but I have never been able to reproduce it.
I can reproduce FunctionExpressionInvocationImpl
issue with
class A {
A(): super(0) = 0;
}
Basically, any cast anywhere is a potential land mine.
Yeah, thank you, that was the case (I forgot to add =
to the example).
As for the stack traces - since LSP requests code actions on typing, I think all of them appear while typing, "randomly". I've almost got a repro, but then the issue stopped appearing.
As for LibraryReader._readClassElement
- I had it like 20 minutes ago.
[Error - 21:51:59] An error occurred while handling textDocument/codeAction request: RangeError (index): Index out of range: index should be less than 1: 1
#0 Uint32List.[] (dart:typed_data-patch/typed_data_patch.dart:2594:7)
#1 LibraryReader._readClassElement (package:analyzer/src/summary2/bundle_reader.dart:617:45)
but again, it's all the same. Here is the full log fullLog.txt
@scheglov I see you committed a few changes referencing this issue; do we need new reproductions in newer Dart versions? Should we close this until we see a newer reproduction?
jfyi, this one is still happening (Dart SDK version: 3.2.0-210.1.beta (beta))
[Error - 19:23:37] An error occurred while handling textDocument/codeAction request: Bad state: Expected existing element: root::package:dcm_analyzer/src/init/baseline/baseline_runner.dart::@unit::package:dcm_analyzer/src/init/baseline/baseline_runner.dart
#0 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:206:7)
#1 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:198:25)
#2 LinkedElementFactory.buildExportNamespace (package:analyzer/src/summary2/linked_element_factory.dart:91:21)
I think _readClassElement
was worked around.
The issue with LibraryElementExtensions.exportedExtensions
is still present, I believe this is a race condition in the server. We don't expect that there is another request (change file) while we look for elements declared in known libraries.
The following example crashes the analysis server:
Dart SDK version: 2.19.4 (stable) (Tue Mar 7 09:58:46 2023 +0000) on "macos_x64"