Conversation
No need to manually use a continuation with lock
This test is an inversion of the `echoInterleave()` test. When the client makes the request to the /speak endpoint, the server immediately starts writing 2-byte chunks to the client and expects the client to “echo” each chunk back to the server before continuing to the next chunk. The server sends 1000 “AB” chunks and then the terminating chunk. The client will see the terminating chunk and also end the request body. This test is disabled because it does not work correctly with URLSession. The client does not process the terminating chunk from the server’s response body, so the request hangs at the end.
guoye-zhang
reviewed
Feb 18, 2026
fabianfett
reviewed
Feb 18, 2026
A task is not necessary when we can write and read in lockstep in the server code.
fabianfett
reviewed
Feb 20, 2026
Comment on lines
61
to
62
| // TODO: URLSession client hangs when it receives the complete response body before it writes its complete request body. | ||
| // try await testSpeakInterleave() |
Member
There was a problem hiding this comment.
I think you should implement task cancellation here after 10sec and fail the test then. withTimeout(.seconds(10)) {}
Collaborator
Author
There was a problem hiding this comment.
I tried something like this, but it didn't seem to work.
withTimeout(..)
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
public func withTimeout(seconds: Int, block: @Sendable @escaping () async throws -> Void) async throws {
try await withThrowingTaskGroup { group in
group.addTask {
try await block()
}
group.addTask {
do {
try await Task.sleep(for: .seconds(seconds))
} catch {
// Ignore cancellation of the timer
}
}
// Wait for either the task to complete or
// for the timer to fire.
try await group.next()
// Cancel everything else.
group.cancelAll()
}
}The timer does appear to fire, but cancellation of the task group doesn't unblock the test. I think the test is just uncooperative when it hangs?
LMK if I'm doing it wrong somehow.
Member
There was a problem hiding this comment.
This is another big test case that we need! Cooperative task cancellation should unblock requests ASAP.
fabianfett
reviewed
Feb 20, 2026
…ave test. Now that we are using single-byte chunks for echo and speak tests, these tests will hang on URLSession, so we have kept them disabled for now.
FranzBusch
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This test is the reverse of the echo test. When the client makes the request to the
/speakendpoint, the server immediately starts writing 1-byte chunks to the client as the response body.The server expects the client to “echo” each chunk back in the request body before it writes the next chunk.
The server sends 1000 “A” chunks and then the terminating chunk. The client will see the terminating chunk and also send the terminating chunk for the request body.
This test (and the Echo test) are disabled because URLSession has issues with bi-directional streaming support:
These tests do pass with other HTTP Client implementations.