fix(test): add timeout to prevent indefinite blocking in StdioClientTransportTest (#514) (#528)

- Introduced `withTimeout` to avoid indefinite hangs during test
execution (#514)

## Motivation and Context
Workaround for #514 in tests

## How Has This Been Tested?
Integration test updated, CI

## Breaking Changes
No

## Types of changes
- [x] Test fix

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
#514
This commit is contained in:
Konstantin Pavlov 2026-02-17 12:16:32 +02:00 • committed by GitHub
commit efed85ae06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,7 @@ import io.modelcontextprotocol.kotlin.test.utils.createTeeProcessBuilder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.withTimeout
import kotlinx.io.asSink
import kotlinx.io.asSource
import kotlinx.io.buffered
@ -56,8 +57,11 @@ class StdioClientTransportTest : BaseTransportTest() {
)
// The error in stderr should cause connecting to fail
// Use explicit timeout to avoid blocking indefinitely due to kotlinx.io cancellation issue (#514)
assertThrows<McpException> {
client.connect(transport)
withTimeout(5.seconds) {
client.connect(transport)
}
}
process.destroyForcibly()