Skip to content

[analysis_server] Bad state:: Expected existing element and Invalid file path errors #48082

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

Closed
osaxma opened this issue Jan 5, 2022 · 4 comments
Labels
legacy-area-analyzer Use area-devexp instead. needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request

Comments

@osaxma
Copy link
Contributor

osaxma commented Jan 5, 2022

Issue:

The analysis server is throwing Bad state:: Expected existing element and Invalid file path errors in a project that I'm working on. I'm observing the errors in VS Code and the error persist even after restarting VS Code entirely (I assume that will be equivalent to restarting the analysis server). Also due to that error, all requests to the server are failing (e.g. hovering over definition or go-to definition).

In fact, this is the second time I face this issue. The first time I filed it here at Dart-Code#3726. The issue disappeared on its own after restarting VS Code multiple times (given that I had multiple projects open at the time so maybe switching between them helped). Now, every time I open VS Code for the same project, I'm getting the errors shown in the logs below (edit: see update below -- opening another project made it the issue disappear).

Logs

The following is a sample extracted from the analyzerInstrumentation log file attached below. This is the first error after opening a fresh instance of VS Code for the project in question.

1641397275008:Ex:Analysis failed:: /Users/osaxma/Projects/super_editor/super_editor/test/editor_smoke_tests/editor_entry_smoke_test.dart context:: exception_20220105_184114_892
Bad state:: Expected existing element:: root::::package::super_editor/src/infrastructure/_logging.dart::::@unit::::package::super_editor/src/infrastructure/_logging.dart::::@getter::::editorImeLog
#0      LinkedElementFactory.elementOfReference (package::analyzer/src/summary2/linked_element_factory.dart::143::7)
#1      LinkedElementFactory.buildExportNamespace (package::analyzer/src/summary2/linked_element_factory.dart::49::21)
#2      LibraryElementImpl.exportNamespace (package::analyzer/src/dart/element/element.dart::3761::42)
#3      NamespaceBuilder._getExportMapping (package::analyzer/src/dart/resolver/scope.dart::269::20)
#4      NamespaceBuilder.getImportedElements (package::analyzer/src/dart/resolver/scope.dart::209::15)
#5      new PrefixScope (package::analyzer/src/dart/element/scope.dart::142::48)
#6      new _LibraryImportScope (package::analyzer/src/dart/element/scope.dart::250::28)
#7      new LibraryScope (package::analyzer/src/dart/element/scope.dart::99::15)
#8      LibraryElementImpl.scope (package::analyzer/src/dart/element/element.dart::3964::23)
#9      new ReferenceResolver (package::analyzer/src/summary2/reference_resolver.dart::45::32)
#10     LibraryBuilder.resolveTypes (package::analyzer/src/summary2/library_builder.dart::161::22)
#11     Linker._resolveTypes (package::analyzer/src/summary2/link.dart::204::15)
#12     Linker._buildOutlines (package::analyzer/src/summary2/link.dart::91::5)
#13     Linker.link (package::analyzer/src/summary2/link.dart::74::5)
#14     link (package::analyzer/src/summary2/link.dart::33::10)
#15     LibraryContext.load2.loadBundle (package::analyzer/src/dart/analysis/library_context.dart::171::30)
#16     LibraryContext.load2.<anonymous closure> (package::analyzer/src/dart/analysis/library_context.dart::201::7)
#17     PerformanceLog.run (package::analyzer/src/dart/analysis/performance_logger.dart::32::15)
#18     LibraryContext.load2 (package::analyzer/src/dart/analysis/library_context.dart::199::12)
#19     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package::analyzer/src/dart/analysis/driver.dart::1367::24)
#20     PerformanceLog.run (package::analyzer/src/dart/analysis/performance_logger.dart::32::15)
#21     AnalysisDriver._computeAnalysisResult (package::analyzer/src/dart/analysis/driver.dart::1354::20)
#22     AnalysisDriver.performWork (package::analyzer/src/dart/analysis/driver.dart::1175::22)
#23     AnalysisDriverScheduler._run (package::analyzer/src/dart/analysis/driver.dart::2062::24)
<asynchronous suspension>


#0      LibraryContext._throwLibraryCycleLinkException (package::analyzer/src/dart/analysis/library_context.dart::262::5)
#1      LibraryContext.load2.loadBundle (package::analyzer/src/dart/analysis/library_context.dart::176::11)
#2      LibraryContext.load2.<anonymous closure> (package::analyzer/src/dart/analysis/library_context.dart::201::7)
#3      PerformanceLog.run (package::analyzer/src/dart/analysis/performance_logger.dart::32::15)
#4      LibraryContext.load2 (package::analyzer/src/dart/analysis/library_context.dart::199::12)
#5      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package::analyzer/src/dart/analysis/driver.dart::1367::24)
#6      PerformanceLog.run (package::analyzer/src/dart/analysis/performance_logger.dart::32::15)
#7      AnalysisDriver._computeAnalysisResult (package::analyzer/src/dart/analysis/driver.dart::1354::20)
#8      AnalysisDriver.performWork (package::analyzer/src/dart/analysis/driver.dart::1175::22)
#9      AnalysisDriverScheduler._run (package::analyzer/src/dart/analysis/driver.dart::2062::24)
<asynchronous suspension>


#0      new SilentException.wrapInMessage (package::analyzer/exception/exception.dart::105::45)
#1      AbstractAnalysisServer.logExceptionResult (package::analysis_server/src/analysis_server_abstract.dart::442::23)
#2      _rootRunUnary (dart::async/zone.dart::1444::13)
#3      _CustomZone.runUnary (dart::async/zone.dart::1335::19)
#4      _CustomZone.runUnaryGuarded (dart::async/zone.dart::1244::7)
#5      _BufferingStreamSubscription._sendData (dart::async/stream_impl.dart::341::11)
#6      _DelayedData.perform (dart::async/stream_impl.dart::591::14)
#7      _StreamImplEvents.handleNext (dart::async/stream_impl.dart::706::11)
#8      _PendingEvents.schedule.<anonymous closure> (dart::async/stream_impl.dart::663::7)
#9      _rootRun (dart::async/zone.dart::1420::47)
#10     _CustomZone.run (dart::async/zone.dart::1328::19)
#11     _CustomZone.runGuarded (dart::async/zone.dart::1236::7)
#12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart::async/zone.dart::1276::23)
#13     _rootRun (dart::async/zone.dart::1428::13)
#14     _CustomZone.run (dart::async/zone.dart::1328::19)
#15     _CustomZone.runGuarded (dart::async/zone.dart::1236::7)
#16     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart::async/zone.dart::1276::23)
#17     _microtaskLoop (dart::async/schedule_microtask.dart::40::21)
#18     _startMicrotaskLoop (dart::async/schedule_microtask.dart::49::5)
#19     _runPendingImmediateCallback (dart::isolate-patch/isolate_patch.dart::122::13)
#20     _Timer._runTimers (dart::isolate-patch/timer_impl.dart::402::11)
#21     _RawReceivePortImpl._handleMessage (dart::isolate-patch/isolate_patch.dart::192::12)

Probably Related Issue:

The following issue describes a probably similar errors that has been appearing frequently as well:

Attachement:

As mentioned above, this log is from a fresh start of VS Code where the error was happening:

Dart SDK Version

Dart SDK version: 2.15.1 (stable) (Tue Dec 14 13:32:21 2021 +0100) on "macos_x64"

Additional Details:

  • The project in question is an open source project located at the following repository:

  • The error occurred after I switched to my local branch and I was viewing the following file:

    • /Users/osaxma/Projects/super_editor/super_editor/test/src/default_editor/super_editor_test.dart
  • The issue is only happening at /Users/osaxma/Projects/super_editor/super_editor/ project. When I opened another project, it was working fine (even the first time, the issue occurred at the same project, and same branch -- autofocus branch on my fork).

Update:

I just opened a different project, then closed it and then I reopened super_editor project, and the issue was gone (no more errors).

I hope these information are helpful. Unfortunately, I'm not able to reproduce as in both times it happened at random but I can say for sure that in both times it happened after I switched from one branch to another.

@osaxma
Copy link
Contributor Author

osaxma commented Jan 5, 2022

FYI: I was looking around there and found these three files. I made a copy of them in case they're useful:

[~]$ ll ~/.dartServer/.analysis-driver | grep exception
-rw-r--r--   1 osaxma  staff    21M Jan  5 18:39 exception_20220105_183910_745-temp-89555
-rw-r--r--   1 osaxma  staff    21M Jan  5 20:37 exception_20220105_203751_749-temp-91793
-rw-r--r--   1 osaxma  staff    21M Jan  5 20:37 exception_20220105_203752_035-temp-91793

@lrhn lrhn added the legacy-area-analyzer Use area-devexp instead. label Jan 5, 2022
@scheglov scheglov added needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request labels Jan 18, 2022
@scheglov
Copy link
Contributor

Unfortunately these are hard to track - they represent a bug in tracking dependencies, changes to files, and invalidation of library elements. If by any chance anything of this is reproducible, I'd love to know about it.

@DanTup
Copy link
Collaborator

DanTup commented Mar 7, 2022

This came up at Dart-Code/Dart-Code#2764 (comment) too.

@leedstyh can you reliably reproduce this? Can you provide steps that might help trigger it?

@github-actions
Copy link

Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll re-open the case if you do. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. needs-info We need additional information from the issue author (auto-closed after 14 days if no response) P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants