ktorio / ktorio/ktor

Flaky: CIOHttpServerTest.testCanModifyRequestBody on mingwX64

Open
#5,478 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
14.5k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
49

Description

## Description

`io.ktor.tests.server.cio.CIOHttpServerTest.testCanModifyRequestBody[mingwX64]` fails intermittently on TeamCity Windows native builds with no stack trace - only stdout showing the server started successfully.

## Observed behavior

The test fails without a clear error message. The server starts and logs:
```
[INFO] (io.ktor.test): Application started in 0.001 seconds.
[INFO] (io.ktor.test): Responding at http://127.0.0.1:62658
```

But the test is marked as failed with no assertion error or exception trace.

## Context

- Observed in build [#412611](https://ktor.teamcity.com/buildConfiguration/Ktor_KtorMatrixNativeWindowsX64/412611)
- The test passes on all other native platforms (macOS arm64, macOS x64, Linux x64)
- Windows native builds consistently show 1-2 random test failures per run (different tests each time), suggesting a systemic Windows-specific flakiness issue
- The test uses `GlobalScope.writer` for request body modification, which may have timing issues on Windows native

## Root cause hypothesis

The test uses `GlobalScope.writer` to intercept and modify the request body on the server side. On Windows native, coroutine scheduling differences may cause a race condition or timeout. The lack of a stack trace suggests the test may be timing out rather than failing with an assertion.

## Reproduction

Cannot reproduce locally on macOS. Requires Windows native environment with TeamCity.

Contributor guide

Open the contributing guide

Research direction

Start with io.ktor.tests.server.cio.CIOHttpServerTest.testCanModifyRequestBody[mingwX64] and the TeamCity build #412611, then examine the GlobalScope.writer usage and Windows native test output. Reproduce or isolate the intermittent failure in a Windows native environment; done means the test no longer flakes and failures expose a useful error.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
operating-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.