bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://github.com/bazelbuild/intellij/blob/master/docs/index.md
Apache License 2.0
762 stars 305 forks source link

Exception when running sync on a fresh kotlin project #6073

Open tpasternak opened 9 months ago

tpasternak commented 9 months ago

Description of the bug:

java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
    at com.intellij.util.SlowOperations.assertSlowOperationsAreAllowed(SlowOperations.java:101)
    at com.intellij.openapi.vfs.newvfs.persistent.FSRecordsImpl.update(FSRecordsImpl.java:735)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.persistAllChildren(PersistentFSImpl.java:382)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.listAll(PersistentFSImpl.java:445)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.loadAllChildren(VirtualDirectoryImpl.java:408)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.getChildren(VirtualDirectoryImpl.java:401)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:313)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:334)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$LibraryKindScanner$Companion.runScannerOutsideScanningSession(LibraryEffectiveKindProvider.kt:123)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.KOTLIN_LIBRARY_KIND_GIST$lambda$3(LibraryEffectiveKindProvider.kt:60)
    at com.intellij.util.gist.VirtualFileGistOverGistStorage.getOrCalculateAndCache(VirtualFileGistOverGistStorage.java:76)
    at com.intellij.util.gist.VirtualFileGistOverGistStorage.getFileData(VirtualFileGistOverGistStorage.java:37)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$findKind$1.invoke(LibraryEffectiveKindProvider.kt:80)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$findKind$1.invoke(LibraryEffectiveKindProvider.kt:80)
    at com.intellij.openapi.application.ActionsKt.runReadAction$lambda$3(actions.kt:31)
    at com.intellij.openapi.application.impl.RwLockHolder.runReadAction(RwLockHolder.kt:271)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:838)
    at com.intellij.openapi.application.ActionsKt.runReadAction(actions.kt:31)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.findKind(LibraryEffectiveKindProvider.kt:80)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.getEffectiveKind(LibraryEffectiveKindProvider.kt:101)
    at org.jetbrains.kotlin.idea.base.platforms.KotlinLibraryKindKt.detectLibraryKind(KotlinLibraryKind.kt:82)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isSupported(StdlibDetectorFacility.kt:44)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isStdlib(StdlibDetectorFacility.kt:22)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isStdlib$default(StdlibDetectorFacility.kt:17)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.isKotlinLibrary(KotlinWithLibraryConfigurator.kt:272)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.getKotlinLibrary(KotlinWithLibraryConfigurator.kt:207)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.getOrCreateKotlinLibrary(KotlinWithLibraryConfigurator.kt:139)
    at com.google.idea.sdkcompat.kotlin.KotlinCompat.lambda$configureModule$0(KotlinCompat.java:67)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:204)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:823)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:420)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:101)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithEnabledImplicitRead(RwLockHolder.kt:138)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithImplicitRead(RwLockHolder.kt:129)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1145)
    at com.intellij.openapi.application.impl.FlushQueue.doRun$$$capture(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:124)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:44)
    at java.desktop/java.awt.event.InvocationEvent.dispatch$$$capture(InvocationEvent.java:318)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:703)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$12(IdeEventQueue.kt:596)
    at com.intellij.openapi.application.impl.RwLockHolder.runWithoutImplicitRead(RwLockHolder.kt:105)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:596)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:77)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:362)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:361)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:361)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:356)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1026)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1026)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:356)
    at com.intellij.openapi.application.impl.RwLockHolder.runIntendedWriteActionOnCurrentThread(RwLockHolder.kt:209)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:823)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:398)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Import a kotlin project.
  2. Clean targets and directories sections in the projectview
  3. Run "Non-incremental sync"
  4. Run "Invalidate caches" action, including file system cache
  5. Restart intellij
  6. Make targets and directories sections include some kotlin files
  7. Run "Non-incremental sync" again

Which Intellij IDE are you using? Please provide the specific version.

Build #IU-241.11761.10, built on February 6, 2024

What programming languages and tools are you using? Please provide specific versions.

No response

What Bazel plugin version are you using?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

tpasternak commented 9 months ago

On the other hand, if I move getOrCreateKotlinLibrary outside invokeAndWait (EDT), I'm getting this:

java.lang.IllegalStateException: Current thread: Thread[BlazeSyncManager-0,5,main]; expected: Thread[AWT-EventQueue-0,6,main]
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkWriteThreadAccess(ReadMostlyRWLock.java:315)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.checkForPossibilityOfWriteLock(ReadMostlyRWLock.java:250)
    at com.intellij.openapi.application.impl.RwLockHolder.startWrite(RwLockHolder.kt:507)
    at com.intellij.openapi.application.impl.RwLockHolder.runWriteAction(RwLockHolder.kt:352)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:881)
    at com.intellij.openapi.application.ActionsKt.runWriteAction(actions.kt:16)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.createNewLibrary(KotlinWithLibraryConfigurator.kt:254)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.getOrCreateKotlinLibrary(KotlinWithLibraryConfigurator.kt:139)
    at com.google.idea.sdkcompat.kotlin.KotlinCompat.configureModule(KotlinCompat.java:67)
    at com.google.idea.blaze.kotlin.sync.BlazeKotlinSyncPlugin$Listener.afterSync(BlazeKotlinSyncPlugin.java:319)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.afterSync(SyncPhaseCoordinator.java:788)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.finishSync(SyncPhaseCoordinator.java:664)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.updateProjectAndFinishSync(SyncPhaseCoordinator.java:592)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.runSync(SyncPhaseCoordinator.java:464)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.lambda$syncProject$0(SyncPhaseCoordinator.java:259)
    at com.google.idea.blaze.base.scope.Scope.push(Scope.java:57)
    at com.google.idea.blaze.base.sync.SyncPhaseCoordinator.lambda$syncProject$1(SyncPhaseCoordinator.java:239)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTask$0(ProgressiveTaskWithProgressIndicator.java:83)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$4(ProgressiveTaskWithProgressIndicator.java:131)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:76)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:46)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:78)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:76)
    at com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator.lambda$submitTaskWithResult$5(ProgressiveTaskWithProgressIndicator.java:131)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
tpasternak commented 1 month ago

cc @LeFrosch @ujohnny