Skip to content

Commit 1cc4344

Browse files
committed
Fix
Tool: gitpod/catfood.gitpod.cloud
1 parent 6f40cdb commit 1cc4344

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/AbstractGitpodPortForwardingService.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,31 @@ abstract class AbstractGitpodPortForwardingService : GitpodPortForwardingService
157157

158158
coroutineScope {
159159
// Stop operations first to free up resources
160-
launch {
160+
val stopForwardingJob = launch {
161161
processPortsInBatches(forwardedPortsToStopForwarding) { port ->
162162
operationSemaphore.withPermit { stopForwarding(port) }
163163
}
164164
}
165-
launch {
165+
val stopExposingJob = launch {
166166
processPortsInBatches(exposedPortsToStopExposingOnClient) { port ->
167167
operationSemaphore.withPermit { stopExposingOnClient(port) }
168168
}
169169
}
170170

171171
// Wait for stop operations to complete
172-
awaitAll()
172+
stopForwardingJob.join()
173+
stopExposingJob.join()
173174

174175
// Start new operations
175-
launch {
176+
val startForwardingJob = launch {
176177
processPortsInBatches(servedPortsToStartForwarding) { port ->
177178
operationSemaphore.withPermit {
178179
startForwarding(port)
179180
allPortsToKeep.add(port.localPort)
180181
}
181182
}
182183
}
183-
launch {
184+
val startExposingJob = launch {
184185
processPortsInBatches(exposedPortsToStartExposingOnClient) { port ->
185186
operationSemaphore.withPermit {
186187
startExposingOnClient(port)
@@ -189,11 +190,12 @@ abstract class AbstractGitpodPortForwardingService : GitpodPortForwardingService
189190
}
190191
}
191192

192-
// Wait for all operations to complete
193-
awaitAll()
193+
// Wait for start operations to complete
194+
startForwardingJob.join()
195+
startExposingJob.join()
194196

195197
// Update presentation in batches to avoid UI thread blocking
196-
launch {
198+
val updatePresentationJob = launch {
197199
portsList.chunked(UI_UPDATE_BATCH_SIZE).forEach { batch ->
198200
application.invokeLater {
199201
batch.forEach { port ->
@@ -205,7 +207,8 @@ abstract class AbstractGitpodPortForwardingService : GitpodPortForwardingService
205207
}
206208
}
207209

208-
awaitAll()
210+
// Wait for UI updates to complete
211+
updatePresentationJob.join()
209212

210213
// Clean up after all operations are done
211214
cleanupUnusedLifetimes(allPortsToKeep)

0 commit comments

Comments
 (0)