dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.09k stars 1.56k forks source link

analyzer SERVER_ERROR for allowed_experiments.json: Cannot open file #50681

Open Hixie opened 1 year ago

Hixie commented 1 year ago

I saw the following, probably when switching branches or upgrading Flutter while the analyzer was running:

Error response from the server: SERVER_ERROR
FileSystemException(path=/home/ianh/dev/flutter/bin/cache/dart-sdk/lib/_internal/allowed_experiments.json; message=Cannot open file)
#0      _PhysicalFile.readAsStringSync (package:analyzer/file_system/physical_file_system.dart:158:7)
#1      _OverlayFile.readAsStringSync (package:analyzer/file_system/overlay_file_system.dart:196:18)
#2      FolderBasedDartSdk.allowedExperimentsJson (package:analyzer/src/dart/sdk/sdk.dart:412:10)
#3      FeatureSetProvider._experimentsForSdk (package:analyzer/src/dart/analysis/feature_set_provider.dart:150:34)
#4      FeatureSetProvider.build (package:analyzer/src/dart/analysis/feature_set_provider.dart:137:30)
#5      AnalysisDriver._createFileTracker (package:analyzer/src/dart/analysis/driver.dart:1469:45)
#6      new AnalysisDriver (package:analyzer/src/dart/analysis/driver.dart:291:5)
#7      ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:130:18)
#8      new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:93:36)
#9      ContextManagerImpl._createAnalysisContexts.performContextRebuildGuarded.performContextRebuild
(package:analysis_server/src/context_manager.dart:463:40)
<asynchronous suspension>
#10     ContextManagerImpl._createAnalysisContexts.performContextRebuildGuarded (package:analysis_server/src/context_manager.dart:606:11)
<asynchronous suspension>
bwilkerson commented 1 year ago

@scheglov

Hixie commented 1 year ago

Got a more serious one today (unfortunately I accidentally blew away the console before I could copy the stack) where it actually crashed the analyzer entirely. Looks like the analyzer in general is very sensitive to sudden filesystem changes of the kind you see when switching git branches.

Hixie commented 1 year ago

Steps to reproduce are something like this:

  1. Run ulimit -Sn unlimited.
  2. Check out flutter's master branch.
  3. In the flutter repo, run flutter update-packages; flutter analyze --watch --write /tmp/analysis --flutter-repo
  4. Change to a branch with a different version of the engine, e.g. flutter channel stable or the equivalent with git.
  5. Run flutter doctor -v or flutter upgrade or flutter test or similar to cause it to download the different Dart.

The analyzer suddenly throws the exception above.