Skip to content

[IJ Plugin] Fix pulling normalized cache for recent AS #6437

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

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ package com.apollographql.ijplugin.apollodebugserver
import com.android.ddmlib.IDevice
import com.android.tools.idea.adb.AdbShellCommandsUtil
import com.apollographql.apollo.ApolloClient
import com.apollographql.apollo.api.ApolloRequest
import com.apollographql.apollo.api.ApolloResponse
import com.apollographql.apollo.api.Operation
import com.apollographql.apollo.network.NetworkTransport
import com.apollographql.apollo.network.http.LoggingInterceptor
import com.apollographql.ijplugin.util.apollo3
import com.apollographql.ijplugin.util.apollo4
import com.apollographql.ijplugin.util.executeCatching
import com.apollographql.ijplugin.util.logd
import com.apollographql.ijplugin.util.logw
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import java.io.Closeable

private const val SOCKET_NAME_PREFIX = "apollo_debug_"
Expand Down Expand Up @@ -65,6 +71,13 @@ class ApolloDebugClient(
.addHttpInterceptor(LoggingInterceptor { line ->
logd("ApolloDebugClient HTTP - $line")
})
// Use a dummy NetworkTransport for subscriptions (which are not used), because the default one
// references CoroutineDispatcher.limitedParallelism which doesn't exist in certain IDE versions.
// (See https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#coroutinesLibraries)
Comment on lines +74 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Is there a Youtrack to remove this limitation? We're able to workaround for now but it's not great moving forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find one, so I opened https://youtrack.jetbrains.com/issue/IJPL-182123

.subscriptionNetworkTransport(object: NetworkTransport{
override fun <D : Operation.Data> execute(request: ApolloRequest<D>): Flow<ApolloResponse<D>> = emptyFlow()
override fun dispose() {}
})
.build()

private fun createPortForward() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.apollographql.ijplugin.normalizedcache

import com.android.adblib.DeviceSelector
import com.android.adblib.syncRecv
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import com.android.tools.idea.adb.AdbShellCommandsUtil
import com.android.tools.idea.adblib.AdbLibApplicationService
import com.android.tools.idea.adblib.ddmlibcompatibility.toDeviceSelector
import com.apollographql.ijplugin.util.execute
import com.apollographql.ijplugin.util.executeCatching
import com.apollographql.ijplugin.util.logd
Expand Down Expand Up @@ -75,7 +75,7 @@ suspend fun pullFile(device: IDevice, appPackageName: String, remoteDirName: Str
val adbLibSession = AdbLibApplicationService.instance.session
val fileChannel = adbLibSession.channelFactory.createFile(Paths.get(localFile.absolutePath))
fileChannel.use {
adbLibSession.deviceServices.syncRecv(device.toDeviceSelector(), intermediateRemoteFilePath, fileChannel)
adbLibSession.deviceServices.syncRecv(DeviceSelector.fromSerialNumber(device.serialNumber), intermediateRemoteFilePath, fileChannel)
}
} finally {
commandResult = shellCommandsUtil.execute("rm $intermediateRemoteFilePath")
Expand Down
Loading