kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.IO, com.github.xnchung.squire.service.DaggerComponentService$doWork$dumb$1$1$1@49cb8ea4]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.kt:130)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:107)
at kotlinx.coroutines.internal.SoftLimitedDispatcher$Worker.run(SoftLimitedDispatcher.kt:130)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:613)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:1183)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:778)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:765)
the code is
@Service(Service.Level.PROJECT)
internal class DaggerComponentService(private val project: Project, private val coroutineScope: CoroutineScope) {
companion object {
fun getInstance(project: Project): DaggerComponentService = project.service()
}
private val logger: Logger = thisLogger()
fun doWork() {
// KotlinRestrictedAnalysisService.getInstance(project)
val dumb = DumbService.getInstance(project).runWhenSmart {
coroutineScope.launch {
withContext(Dispatchers.IO) {
readActionBlocking {
logger.warn("DaggerComponentService is doing work...")
// coroutineScope.launch(Dispatchers.EDT) {
logger.warn("DaggerComponentService start work...")
// withContext(Dispatchers.IO) {
logger.warn("DaggerComponentService start work...1")
val allScope = GlobalSearchScope.projectScope(project)
val annotationFQN = "dagger.Component"
val clazz =
project.service<JavaPsiFacade>().findClass(annotationFQN, allScope)
val searchPsiClasses = clazz?.let { AnnotatedElementsSearch.searchPsiClasses(it, allScope) }
logger.warn(searchPsiClasses?.toList().toString())
StubIndex.getElements(
KotlinAnnotationsIndex.indexKey,
"Module",
project,
allScope,
KtAnnotationEntry::class.java
).forEach {
logger.warn("KotlinAnnotationsIndex: ${it}")
}
// }
}
}
}.invokeOnCompletion {
logger.warn("doWork() with result: $it")
}
}
}
}
My guess is that your plugin is bundling its own copy of kotlin coroutines, but with a different version than the platform’s library.
Don’t bundle the library, but rely on the platform’s library instead.
18:48:50: Executing 'dependencyInsight --configuration runtimeClasspath --dependency org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm'…
Calculating task graph as no cached configuration is available for tasks: dependencyInsight --configuration runtimeClasspath --dependency org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm
> Task :dependencyInsight
No dependencies matching given input were found in configuration ':runtimeClasspath'
18:51:21: Executing 'dependencyInsight --configuration compileClasspath --dependency org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm'…
Calculating task graph as no cached configuration is available for tasks: dependencyInsight --configuration compileClasspath --dependency org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm
> Task :dependencyInsight
No dependencies matching given input were found in configuration ':compileClasspath'
BUILD SUCCESSFUL in 8s
no any coroutines lib found in compile and runtime classpath ,but it appears in kotlinBuildToolsApiClasspath and kotlinCompilerClasspath
It seems to be a version compatibility issue. I downgraded my Kotlin version from 2.3 to 2.1, and the problem disappeared. Coroutines rely on the compiler and compiler plugins to work, which indirectly depends on the Kotlin version.