Skip to content

Commit 5b983f5

Browse files
authored
Added Ktor closure tests and Cancellation tests, + minor fixes (#479)
1 parent 9118e45 commit 5b983f5

File tree

25 files changed

+355
-109
lines changed

25 files changed

+355
-109
lines changed

docs/environment.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Here is a 'simple' guide for solving problems:
392392
- Docker
393393
- `Cannot connect to the Docker daemon` - open `Docker Desktop`
394394
- Kotlin/Js or Kotlin/Wasm
395-
- `kotlinUpgradePackageLock` or `kotlinWasmUpgradePackageLock` (and also `kotlinNpmInstall` or `kotlinWasmNpmInstall`)
395+
- `kotlinUpgradeYarnLock` or `kotlinWasmUpgradeYarnLock` (and also `kotlinNpmInstall` or `kotlinWasmNpmInstall`)
396396
have a funny tendency to fail sometimes, and you don't know why.
397397

398398
I'll tell you!
@@ -403,7 +403,7 @@ Here is a 'simple' guide for solving problems:
403403
If something doesn't work, your steps are:
404404
- Delete `package-lock.json` file
405405
- Delete `<REPO_ROOT>/build/js` / `<REPO_ROOT>/build/wasm`
406-
- Run `kotlinUpgradePackageLock` / `kotlinWasmUpgradePackageLock`
406+
- Run `kotlinUpgradeYarnLock` / `kotlinWasmUpgradeYarnLock`
407407
- If the problem persists:
408408
- Check that `<REPO_ROOT>/build/<target>/.npmrc` AND `<REPO_ROOT>/build/<target>/.yarnrc` are present
409409
- Check that `.yarnrc` contains one line: `registry: "https://packages.jetbrains.team/npm/p/krpc/build-deps/"`
@@ -479,7 +479,7 @@ all included builds (not subprojects) must reflect the change.
479479
- `checkLegacyAbi` / `updateLegacyAbi` - ABI checks.
480480
See https://kotlinlang.org/docs/whatsnew22.html#binary-compatibility-validation-included-in-kotlin-gradle-plugin.
481481
Former BCV: https://github.com/Kotlin/binary-compatibility-validator
482-
- `kotlinUpgradePackageLock` / `kotlinWasmUpgradePackageLock` - update [kotlin-js-store](../kotlin-js-store) contents,
482+
- `kotlinUpgradeYarnLock` / `kotlinWasmUpgradeYarnLock` - update [kotlin-js-store](../kotlin-js-store) contents,
483483
usually after Kotlin version update.
484484
- `updateDocsChangelog` - put modified [CONTRIBUTING.md](../CONTRIBUTING.md) into [topics](pages/kotlinx-rpc/topics)
485485
- `detekt` - run detekt checks.

gradle-conventions/src/main/kotlin/util/tasks/npm.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import org.gradle.kotlin.dsl.assign
1010
import org.gradle.kotlin.dsl.configure
1111
import org.gradle.kotlin.dsl.provideDelegate
1212
import org.gradle.kotlin.dsl.withType
13+
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
1314
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
1415
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
1516
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootEnvSpec
17+
import org.jetbrains.kotlin.gradle.targets.wasm.nodejs.WasmNodeJsRootExtension
1618
import org.jetbrains.kotlin.gradle.targets.wasm.yarn.WasmYarnPlugin
1719
import org.jetbrains.kotlin.gradle.targets.wasm.yarn.WasmYarnRootEnvSpec
20+
import org.jetbrains.kotlin.gradle.targets.web.nodejs.BaseNodeJsRootExtension
1821
import org.jetbrains.kotlin.gradle.targets.web.yarn.BaseYarnRootEnvSpec
1922
import org.jetbrains.kotlin.gradle.targets.web.yarn.CommonYarnPlugin
2023
import util.other.optionalProperty
@@ -25,12 +28,13 @@ import java.io.File
2528
private inline fun <
2629
reified Plugin : CommonYarnPlugin,
2730
reified Spec : BaseYarnRootEnvSpec,
31+
reified NodeJsExtension: BaseNodeJsRootExtension,
2832
> Project.registerCustomNpmTasks(
2933
target: String,
3034
useProxy: Boolean,
3135
) {
3236
val capitalizedTarget = target.replaceFirstChar { it.titlecase() }
33-
tasks.register("execute${capitalizedTarget}NpmLogin") {
37+
val login = tasks.register("execute${capitalizedTarget}NpmLogin") {
3438
if (!useProxyRepositories) {
3539
return@register
3640
}
@@ -82,6 +86,12 @@ private inline fun <
8286
downloadBaseUrl = "https://packages.jetbrains.team/files/p/krpc/build-deps/"
8387
}
8488
}
89+
90+
extensions.configure<NodeJsExtension> {
91+
npmInstallTaskProvider.configure {
92+
dependsOn(login)
93+
}
94+
}
8595
}
8696
}
8797

@@ -100,8 +110,8 @@ fun Project.configureNpm() {
100110
val kotlinMasterBuild by optionalProperty()
101111
val useProxy = useProxyRepositories
102112

103-
registerCustomNpmTasks<YarnPlugin, YarnRootEnvSpec>("js", useProxy)
104-
registerCustomNpmTasks<WasmYarnPlugin, WasmYarnRootEnvSpec>("wasm", useProxy)
113+
registerCustomNpmTasks<YarnPlugin, YarnRootEnvSpec, NodeJsRootExtension>("js", useProxy)
114+
registerCustomNpmTasks<WasmYarnPlugin, WasmYarnRootEnvSpec, WasmNodeJsRootExtension>("wasm", useProxy)
105115

106116
// necessary for CI js tests
107117
rootProject.plugins.withType<YarnPlugin> {

kotlin-js-store/wasm/yarn.lock

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==
3636

3737
"@types/node@*":
38-
version "24.5.0"
39-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/@types/node/-/node-24.5.0.tgz#70a482e6b1d50e603729d74e62a9a43705ddc9d7"
40-
integrity sha512-y1dMvuvJspJiPSDZUQ+WMBvF7dpnEqN4x9DDC9ie5Fs/HUZJA3wFp7EhHoVaKX/iI0cRoECV8X2jL8zi0xrHCg==
38+
version "24.5.1"
39+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/@types/node/-/node-24.5.1.tgz#dab6917c47113eb4502d27d06e89a407ec0eff95"
40+
integrity sha512-/SQdmUP2xa+1rdx7VwB9yPq8PaKej8TD5cQ+XfKDPWWC+VDJU4rvVVagXqKUzhKjtFoNA8rXDJAkCxQPAe00+Q==
4141
dependencies:
4242
undici-types "~7.12.0"
4343

@@ -83,9 +83,9 @@ b4a@^1.6.4:
8383
integrity sha512-ZovbrBV0g6JxK5cGUF1Suby1vLfKjv4RWi8IxoaO/Mon8BDD9I21RxjHFtgQ+kskJqLAVyQZly3uMBui+vhc8Q==
8484

8585
bare-events@^2.2.0, bare-events@^2.5.4:
86-
version "2.6.1"
87-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/bare-events/-/bare-events-2.6.1.tgz#f793b28bdc3dcf147d7cf01f882a6f0b12ccc4a2"
88-
integrity sha512-AuTJkq9XmE6Vk0FJVNq5QxETrSA/vKHarWVBG5l/JbdCL1prJemiyJqUS0jrlXO0MftuPq4m3YVYhoNc5+aE/g==
86+
version "2.7.0"
87+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/bare-events/-/bare-events-2.7.0.tgz#46596dae9c819c5891eb2dcc8186326ed5a6da54"
88+
integrity sha512-b3N5eTW1g7vXkw+0CXh/HazGTcO5KYuu/RCNaJbDMPI6LHDi+7qe8EmxKUVe1sUbY2KZOVZFyj62x0OEz9qyAA==
8989

9090
bare-fs@^4.0.1:
9191
version "4.4.4"
@@ -620,12 +620,7 @@ wrappy@1:
620620
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
621621
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
622622

623-
ws@8.18.0:
624-
version "8.18.0"
625-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
626-
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==
627-
628-
ws@^8.18.2:
623+
ws@8.18.3, ws@^8.18.2:
629624
version "8.18.3"
630625
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472"
631626
integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==

kotlin-js-store/yarn.lock

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@
134134
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
135135

136136
"@types/node@*", "@types/node@>=10.0.0":
137-
version "24.5.0"
138-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/@types/node/-/node-24.5.0.tgz#70a482e6b1d50e603729d74e62a9a43705ddc9d7"
139-
integrity sha512-y1dMvuvJspJiPSDZUQ+WMBvF7dpnEqN4x9DDC9ie5Fs/HUZJA3wFp7EhHoVaKX/iI0cRoECV8X2jL8zi0xrHCg==
137+
version "24.5.1"
138+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/@types/node/-/node-24.5.1.tgz#dab6917c47113eb4502d27d06e89a407ec0eff95"
139+
integrity sha512-/SQdmUP2xa+1rdx7VwB9yPq8PaKej8TD5cQ+XfKDPWWC+VDJU4rvVVagXqKUzhKjtFoNA8rXDJAkCxQPAe00+Q==
140140
dependencies:
141141
undici-types "~7.12.0"
142142

@@ -393,9 +393,9 @@ balanced-match@^1.0.0:
393393
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
394394

395395
bare-events@^2.2.0, bare-events@^2.5.4:
396-
version "2.6.1"
397-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/bare-events/-/bare-events-2.6.1.tgz#f793b28bdc3dcf147d7cf01f882a6f0b12ccc4a2"
398-
integrity sha512-AuTJkq9XmE6Vk0FJVNq5QxETrSA/vKHarWVBG5l/JbdCL1prJemiyJqUS0jrlXO0MftuPq4m3YVYhoNc5+aE/g==
396+
version "2.7.0"
397+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/bare-events/-/bare-events-2.7.0.tgz#46596dae9c819c5891eb2dcc8186326ed5a6da54"
398+
integrity sha512-b3N5eTW1g7vXkw+0CXh/HazGTcO5KYuu/RCNaJbDMPI6LHDi+7qe8EmxKUVe1sUbY2KZOVZFyj62x0OEz9qyAA==
399399

400400
bare-fs@^4.0.1:
401401
version "4.4.4"
@@ -810,9 +810,9 @@ ee-first@1.1.1:
810810
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
811811

812812
electron-to-chromium@^1.5.218:
813-
version "1.5.218"
814-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/electron-to-chromium/-/electron-to-chromium-1.5.218.tgz#921042a011a98a4620853c9d391ab62bcc124400"
815-
integrity sha512-uwwdN0TUHs8u6iRgN8vKeWZMRll4gBkz+QMqdS7DDe49uiK68/UX92lFb61oiFPrpYZNeZIqa4bA7O6Aiasnzg==
813+
version "1.5.220"
814+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/electron-to-chromium/-/electron-to-chromium-1.5.220.tgz#a9853fa5edcf51f4c7db369144377cf31d783b8f"
815+
integrity sha512-TWXijEwR1ggr4BdAKrb1nMNqYLTx1/4aD1fkeZU+FVJGTKu53/T7UyHKXlqEX3Ub02csyHePbHmkvnrjcaYzMA==
816816

817817
emoji-regex@^8.0.0:
818818
version "8.0.0"
@@ -858,7 +858,7 @@ engine.io@~6.6.0:
858858

859859
enhanced-resolve@^5.17.2:
860860
version "5.18.3"
861-
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz#9b5f4c5c076b8787c78fe540392ce76a88855b44"
861+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz#9b5f4c5c076b8787c78fe540392ce76a88855b44"
862862
integrity sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==
863863
dependencies:
864864
graceful-fs "^4.2.4"
@@ -1486,7 +1486,7 @@ karma-webpack@5.0.1:
14861486

14871487
karma@6.4.4:
14881488
version "6.4.4"
1489-
resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.4.tgz#dfa5a426cf5a8b53b43cd54ef0d0d09742351492"
1489+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/karma/-/karma-6.4.4.tgz#dfa5a426cf5a8b53b43cd54ef0d0d09742351492"
14901490
integrity sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==
14911491
dependencies:
14921492
"@colors/colors" "1.5.0"
@@ -1521,7 +1521,7 @@ kind-of@^6.0.2:
15211521

15221522
kotlin-web-helpers@2.1.0:
15231523
version "2.1.0"
1524-
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.1.0.tgz#6cd4b0f0dc3baea163929c8638155b8d19c55a74"
1524+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/kotlin-web-helpers/-/kotlin-web-helpers-2.1.0.tgz#6cd4b0f0dc3baea163929c8638155b8d19c55a74"
15251525
integrity sha512-NAJhiNB84tnvJ5EQx7iER3GWw7rsTZkX9HVHZpe7E3dDBD/dhTzqgSwNU3MfQjniy2rB04bP24WM9Z32ntUWRg==
15261526
dependencies:
15271527
format-util "^1.0.5"
@@ -1654,7 +1654,7 @@ mkdirp@^0.5.5:
16541654

16551655
mocha@11.7.1:
16561656
version "11.7.1"
1657-
resolved "https://registry.yarnpkg.com/mocha/-/mocha-11.7.1.tgz#91948fecd624fb4bd154ed260b7e1ad3910d7c7a"
1657+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/mocha/-/mocha-11.7.1.tgz#91948fecd624fb4bd154ed260b7e1ad3910d7c7a"
16581658
integrity sha512-5EK+Cty6KheMS/YLPPMJC64g5V61gIR25KsRItHw6x4hEKT6Njp1n9LOlH4gpevuwMVS66SXaBBpg+RWZkza4A==
16591659
dependencies:
16601660
browser-stdout "^1.3.1"
@@ -2496,7 +2496,7 @@ webpack-sources@^3.3.3:
24962496

24972497
webpack@5.100.2:
24982498
version "5.100.2"
2499-
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.100.2.tgz#e2341facf9f7de1d702147c91bcb65b693adf9e8"
2499+
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/webpack/-/webpack-5.100.2.tgz#e2341facf9f7de1d702147c91bcb65b693adf9e8"
25002500
integrity sha512-QaNKAvGCDRh3wW1dsDjeMdDXwZm2vqq3zn6Pvq4rHOEOGSaUMgOOjG2Y9ZbIGzpfkJk9ZYTHpDqgDfeBDcnLaw==
25012501
dependencies:
25022502
"@types/eslint-scope" "^3.7.7"
@@ -2572,12 +2572,7 @@ wrappy@1:
25722572
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
25732573
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
25742574

2575-
ws@8.18.0:
2576-
version "8.18.0"
2577-
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
2578-
integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==
2579-
2580-
ws@^8.18.2:
2575+
ws@8.18.3, ws@^8.18.2:
25812576
version "8.18.3"
25822577
resolved "https://packages.jetbrains.team/npm/p/krpc/build-deps/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472"
25832578
integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==

krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/KrpcClient.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import kotlinx.coroutines.SupervisorJob
1616
import kotlinx.coroutines.cancel
1717
import kotlinx.coroutines.cancelAndJoin
1818
import kotlinx.coroutines.channels.Channel
19+
import kotlinx.coroutines.channels.ClosedSendChannelException
1920
import kotlinx.coroutines.coroutineScope
2021
import kotlinx.coroutines.currentCoroutineContext
2122
import kotlinx.coroutines.ensureActive
@@ -215,7 +216,9 @@ public abstract class KrpcClient : RpcClient, KrpcEndpoint {
215216
connector.subscribeToGenericMessages(::handleGenericMessage)
216217
connector.subscribeToProtocolMessages(::handleProtocolMessage)
217218

218-
connector.sendMessage(KrpcProtocolMessage.Handshake(KrpcPlugin.ALL))
219+
connector.sendMessageChecked(KrpcProtocolMessage.Handshake(KrpcPlugin.ALL)) {
220+
// ignore, we are already cancelled and have a cause
221+
}
219222
}
220223
}
221224

@@ -476,7 +479,9 @@ public abstract class KrpcClient : RpcClient, KrpcEndpoint {
476479
connectionId = outgoingStream.connectionId,
477480
serviceId = outgoingStream.serviceId,
478481
)
479-
sender.sendMessage(message)
482+
connector.sendMessageChecked(message) {
483+
// ignore, we are already cancelled and have a cause
484+
}
480485

481486
// stop the flow and its coroutine, other flows are not affected
482487
throw e
@@ -490,7 +495,9 @@ public abstract class KrpcClient : RpcClient, KrpcEndpoint {
490495
connectionId = outgoingStream.connectionId,
491496
serviceId = outgoingStream.serviceId,
492497
)
493-
sender.sendMessage(message)
498+
connector.sendMessageChecked(message) {
499+
// ignore, we are already cancelled and have a cause
500+
}
494501

495502
throw cause
496503
}
@@ -543,7 +550,9 @@ public abstract class KrpcClient : RpcClient, KrpcEndpoint {
543550
}
544551
}
545552

546-
sender.sendMessage(message)
553+
sender.sendMessageChecked(message) { e ->
554+
throw CancellationException("Request cancelled", e)
555+
}
547556
}
548557
}
549558

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcConnector.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public interface KrpcMessageSender {
3535
public fun drainSendQueueAndClose(message: String)
3636
}
3737

38+
@InternalRpcApi
39+
public suspend inline fun KrpcMessageSender.sendMessageChecked(
40+
message: KrpcMessage,
41+
onChannelClosed: (ClosedSendChannelException) -> Unit,
42+
) {
43+
try {
44+
sendMessage(message)
45+
} catch (e: ClosedSendChannelException) {
46+
onChannelClosed(e)
47+
}
48+
}
49+
3850
internal typealias KrpcMessageSubscription<Message> = suspend (Message) -> Unit
3951

4052
/**
@@ -72,9 +84,7 @@ public class KrpcConnector(
7284

7385
// prevent errors ping-pong
7486
private suspend fun sendMessageIgnoreClosure(message: KrpcMessage) {
75-
try {
76-
sendMessage(message)
77-
} catch (_: ClosedSendChannelException) {
87+
sendMessageChecked(message) {
7888
// ignore
7989
}
8090
}

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcEndpoint.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public interface KrpcEndpoint {
4444
).toMap()
4545
)
4646

47-
try {
48-
sender.sendMessage(message)
49-
} catch (_: ClosedSendChannelException) {
47+
sender.sendMessageChecked(message) {
5048
// ignore, call was already closed
5149
}
5250
}
@@ -76,7 +74,9 @@ public interface KrpcEndpoint {
7674
connectionId = message.connectionId,
7775
)
7876

79-
sender.sendMessage(failure)
77+
sender.sendMessageChecked(failure) {
78+
// ignore, call was already closed
79+
}
8080
}
8181
}
8282

krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcReceiveHandler.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,15 @@ internal class KrpcActingReceiveHandler(
212212
}
213213

214214
internal suspend fun broadcastWindowUpdate(update: Int, connectionId: Long?, serviceType: String, callId: String) {
215-
try {
216-
sender.sendMessage(
217-
KrpcGenericMessage(
218-
connectionId = connectionId,
219-
pluginParams = mutableMapOf(
220-
KrpcPluginKey.WINDOW_UPDATE to "$update",
221-
KrpcPluginKey.WINDOW_KEY to "$serviceType/$callId",
222-
),
223-
)
215+
sender.sendMessageChecked(
216+
KrpcGenericMessage(
217+
connectionId = connectionId,
218+
pluginParams = mutableMapOf(
219+
KrpcPluginKey.WINDOW_UPDATE to "$update",
220+
KrpcPluginKey.WINDOW_KEY to "$serviceType/$callId",
221+
),
224222
)
225-
} catch (_: ClosedSendChannelException) {
223+
) {
226224
// ignore, connection is closed, no more channel updates are needed
227225
}
228226
}

0 commit comments

Comments
 (0)