Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ env:
CARGO_TERM_COLOR: always

jobs:
current-stable-core:
name: Linux Core (current stable)
runs-on: ubuntu-latest

steps:
- name: Checkout Sources
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rust-src

- name: Cache Core Workspace
uses: Swatinem/rust-cache@v2
with:
key: current-stable-core

- name: Run Core Feature Tests
run: ./scripts/test.sh --core -q

- name: Run Default Library and Response Stream Tests
run: cargo test -p rocket --lib --test response-stream-errors

test:
name: "${{ matrix.platform.name }} ${{ matrix.test.name }} (${{ matrix.platform.toolchain }})"
runs-on: ${{ matrix.platform.distro }}
Expand Down Expand Up @@ -94,7 +118,8 @@ jobs:
uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: ${{ matrix.platform.toolchain }}
# SQLx 0.7.2 relies on unit never-type fallback removed in Rust 1.100.
toolchain: ${{ matrix.platform.toolchain == 'stable' && '1.99.1' || matrix.platform.toolchain }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
components: rust-src

- name: Cache Example Workspace
Expand Down
1 change: 1 addition & 0 deletions core/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ version = "1.0"
version_check = "0.9.1"

[dev-dependencies]
hyper-util = { version = "0.1.21", features = ["client-legacy"] }
hyper = { version = "1.12.0", default-features = false, features = ["client", "http1", "http2"] }
figment = { version = "0.10", features = ["test"] }
pretty_assertions = "1"
20 changes: 18 additions & 2 deletions core/lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,24 @@ impl Rocket<Orbit> {
let body = response.body_mut();
let max_chunk_size = body.max_chunk_size();
let mut stream = body.into_bytes_stream(max_chunk_size);
while let Some(next) = stream.next().await {
sender.send(Ok(Frame::data(next?))).await
loop {
let next = tokio::select! {
biased;
next = stream.next() => next,
_ = sender.closed() => return Err(io::Error::new(
io::ErrorKind::BrokenPipe, "client disconnect during response body")),
};
let Some(next) = next else { break };
let bytes = match next {
Ok(bytes) => bytes,
Err(error) => {
let body_error = io::Error::new(error.kind(), error.to_string());
let _ = sender.send(Err(body_error)).await;
return Err(error);
}
};

sender.send(Ok(Frame::data(bytes))).await
.map_err(|e| io::Error::new(io::ErrorKind::BrokenPipe, e))?;
}

Expand Down
Loading
Loading