Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughRefactors test-server lifecycle to use external CoroutineScope and SupervisorJob, adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96e7252c1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ktor-test-server/src/main/kotlin/test/server/TestServerService.kt`:
- Around line 20-23: Wrap the start-up call in the init block in a try/catch so
any exception during startServer(scope) cancels the service scope before
propagating; specifically, in the init {} surrounding startServer(scope) catch
Throwable, call scope.cancel("startup aborted", it) (or scope.cancel()) to stop
any children launched by startServer, then rethrow the exception (do not
swallow), so close() isn't relied upon to run; reference init,
startServer(scope), scope.cancel(...), and close() when making the change.
In `@ktor-test-server/src/main/kotlin/test/server/TestTcpServer.kt`:
- Around line 30-34: The catch block in TestTcpServer.kt currently calls
ensureActive() but still logs/prints any CancellationException; update the
handler so that if the caught throwable is a CancellationException it is
rethrown (or rethrown after calling ensureActive()) before any
println/cause.printStackTrace/logging occurs; apply the same change to the
second catch site (the block around lines 40-43) so CancellationException is
never logged but propagated immediately.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7fa47237-a3f9-44f9-8bc5-63aa52d465c7
📒 Files selected for processing (6)
ktor-test-server/build.gradle.ktsktor-test-server/src/main/kotlin/test/server/ClientTestServer.ktktor-test-server/src/main/kotlin/test/server/TestServer.ktktor-test-server/src/main/kotlin/test/server/TestServerService.ktktor-test-server/src/main/kotlin/test/server/TestTcpServer.ktktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt
💤 Files with no reviewable changes (3)
- ktor-test-server/build.gradle.kts
- ktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt
- ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt
fae7166 to
2ce48fe
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
ktor-test-server/src/main/kotlin/test/server/TestServer.kt (1)
36-47:⚠️ Potential issue | 🟠 MajorStill misses cleanup when startup fails.
If any
it.start()throws before Line 41 registers the shutdown coroutine, the servers that already started stay alive and keep their ports bound for the rest of the build.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ktor-test-server/src/main/kotlin/test/server/TestServer.kt` around lines 36 - 47, The startup sequence currently starts servers inside runBlocking via servers.map { async { it.start() } } and only afterwards launches the shutdown coroutine (CoroutineName("server-stopper")), so if any it.start() throws the already-started servers remain running; to fix, register the shutdown coroutine (the awaitCancellation finally block that calls it.stop(...)) before initiating starts and/or wrap the start logic in a try/catch that on any exception iterates the servers that have already started and calls it.stop(gracePeriodMillis = 0, timeoutMillis = 0); ensure you reference the existing awaitCancellation shutdown coroutine, the it.start() calls, and the it.stop(...) calls so the cleanup runs on startup failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ktor-test-server/README.md`:
- Around line 11-14: Update the fenced code block in README.md's Example section
to include a language tag (use bash) so the block reads ```bash followed by the
command "./gradlew :ktor-client-core:jvmTest -Pktorbuild.testServer.verbose" and
ending with ```; this will satisfy markdownlint and enable shell syntax
highlighting for the example.
---
Duplicate comments:
In `@ktor-test-server/src/main/kotlin/test/server/TestServer.kt`:
- Around line 36-47: The startup sequence currently starts servers inside
runBlocking via servers.map { async { it.start() } } and only afterwards
launches the shutdown coroutine (CoroutineName("server-stopper")), so if any
it.start() throws the already-started servers remain running; to fix, register
the shutdown coroutine (the awaitCancellation finally block that calls
it.stop(...)) before initiating starts and/or wrap the start logic in a
try/catch that on any exception iterates the servers that have already started
and calls it.stop(gracePeriodMillis = 0, timeoutMillis = 0); ensure you
reference the existing awaitCancellation shutdown coroutine, the it.start()
calls, and the it.stop(...) calls so the cleanup runs on startup failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 419fe0be-1048-4268-88d8-5ed87b8064ac
📒 Files selected for processing (5)
ktor-test-server/README.mdktor-test-server/src/main/kotlin/test/server/ClientTestServer.ktktor-test-server/src/main/kotlin/test/server/TestServer.ktktor-test-server/src/main/kotlin/test/server/TestServerService.ktktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt
- ktor-test-server/src/main/kotlin/test/server/TestServerService.kt
370b636 to
784f10c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 784f10c97f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
ktor-test-server/README.md (1)
12-14:⚠️ Potential issue | 🟡 MinorAdd the missing
bashfence tag.This still trips MD040 and loses shell highlighting. This was already called out on the previous revision.
Suggested fix
-``` +```bash ./gradlew :ktor-client-core:jvmTest -Pktorbuild.testServer.verbose🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ktor-test-server/README.md` around lines 12 - 14, The fenced code block in README.md is missing a language tag which causes MD040 and loses shell highlighting; update the triple-backtick fence surrounding the Gradle command ("./gradlew :ktor-client-core:jvmTest -Pktorbuild.testServer.verbose") to use a bash tag (change ``` to ```bash) so the snippet is syntax-highlighted and MD040 is resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ktor-test-server/README.md`:
- Around line 12-14: The README's Gradle example is missing the value assignment
for the project property; update the command that shows running the jvmTest for
:ktor-client-core to pass the boolean value by changing the property flag to
include "=true" (i.e., use -Pktorbuild.testServer.verbose=true) so the Gradle
property is actually set when demonstrating the test run command.
In `@ktor-test-server/src/main/kotlin/test/server/TestServer.kt`:
- Around line 36-41: The finally block inside
scope.launch(CoroutineName("server-stopper")) currently calls servers.forEach {
it.stop(gracePeriodMillis = 0, timeoutMillis = 0) } which will abort remaining
stops if one throws; update that shutdown loop to stop each server independently
by wrapping each it.stop(...) in its own try/catch so a failure on one server is
caught, logged (include the server identity and exception), and the loop
continues to attempt to stop the rest (you can use a for loop or forEach with an
inner try/catch); ensure the awaitCancellation() and
CoroutineName("server-stopper") logic remains unchanged.
In `@ktor-test-server/src/main/kotlin/test/server/TestTcpServer.kt`:
- Around line 28-37: In ServerSocket.serve(), don't endlessly retry after a
non-cancellation failure from accept(): in the catch block for Throwable
(excluding CancellationException) log the error as you do but then decide to
stop serving for fatal errors instead of continue; specifically detect fatal
conditions (e.g., socket closed/SocketException or the ServerSocket isClosed)
and break/return from the loop or close the ServerSocket to stop the loop,
otherwise for transient errors you may continue; update the catch in
ServerSocket.serve() around accept() to break/return on fatal errors rather than
always continue.
---
Duplicate comments:
In `@ktor-test-server/README.md`:
- Around line 12-14: The fenced code block in README.md is missing a language
tag which causes MD040 and loses shell highlighting; update the triple-backtick
fence surrounding the Gradle command ("./gradlew :ktor-client-core:jvmTest
-Pktorbuild.testServer.verbose") to use a bash tag (change ``` to ```bash) so
the snippet is syntax-highlighted and MD040 is resolved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 930be4a3-2fc4-47a4-9b7c-926390954533
📒 Files selected for processing (7)
ktor-test-server/README.mdktor-test-server/src/main/kotlin/test/server/ClientTestServer.ktktor-test-server/src/main/kotlin/test/server/TestServer.ktktor-test-server/src/main/kotlin/test/server/TestServerService.ktktor-test-server/src/main/kotlin/test/server/TestTcpServer.ktktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.ktktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt
💤 Files with no reviewable changes (1)
- ktor-test-server/src/main/kotlin/test/server/tests/CloseableGroup.kt
✅ Files skipped from review due to trivial changes (1)
- ktor-test-server/src/main/kotlin/test/server/tests/WebSockets.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt
784f10c to
ebe9e8e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ktor-test-server/src/main/kotlin/test/server/ClientTestServer.kt`:
- Around line 29-31: The exception<Throwable> StatusPages handler currently
prints every throwable (exception<Throwable> { call, cause -> ... }) including
CancellationException; update the handler to detect
kotlin.coroutines.cancellation.CancellationException (or cause is
CancellationException) and skip calling cause.printStackTrace() for that case,
only printing the stacktrace for non-cancellation throwables while keeping the
existing call.respondText(...) behavior unchanged for both paths.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cd31ec45-d49f-41a0-b320-85d1e23b9153
📒 Files selected for processing (5)
ktor-test-server/README.mdktor-test-server/settings.gradle.ktsktor-test-server/src/main/kotlin/test/server/ClientTestServer.ktktor-test-server/src/main/kotlin/test/server/TestServer.ktktor-test-server/src/main/kotlin/test/server/TestServerService.kt
✅ Files skipped from review due to trivial changes (2)
- ktor-test-server/settings.gradle.kts
- ktor-test-server/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- ktor-test-server/src/main/kotlin/test/server/TestServer.kt
ebe9e8e to
7bc47c0
Compare
Subsystem
Test Infrastructure
Motivation
Test server prints a lot of exceptions in logs making it expensive for AI tools to analyze the output.
Solution
StatusPagesplugin only when flagktorbuild.testServer.verboseistrueCancellationExceptions