Skip to content

Commit 0fb0ba9

Browse files
committed
fixes
1 parent 992fb74 commit 0fb0ba9

File tree

1 file changed

+12
-9
lines changed
  • apollo-router/src/axum_factory/compression

1 file changed

+12
-9
lines changed

apollo-router/src/axum_factory/compression/mod.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub(crate) enum Compressor {
2626
Zstd(ZstdEncoder),
2727
}
2828

29-
//FIXME: we should call finish at the end
3029
impl Compressor {
3130
pub(crate) fn new<'a, It: 'a>(it: It) -> Option<Self>
3231
where
@@ -89,13 +88,14 @@ where {
8988
partial_output.advance(written);
9089

9190
match self.encode(&mut partial_input, &mut partial_output) {
92-
Err(e) => panic!("{e:?}"),
91+
Err(e) => {
92+
let _ = tx.send(Err(e.into())).await;
93+
return;
94+
}
9395
Ok(()) => {}
9496
}
9597

96-
//let read = partial_input.written().len();
9798
written += partial_output.written().len();
98-
//println!("encode: read from input: {read}, written = {written}");
9999

100100
if !partial_input.unwritten().is_empty() {
101101
// there was not enough space in the output buffer to compress everything,
@@ -105,12 +105,13 @@ where {
105105
buf.reserve(written);
106106
}
107107
} else {
108-
// FIXME: what happens if we try to flush in a full buffer
109108
match self.flush(&mut partial_output) {
110-
Err(e) => panic!("{e:?}"),
109+
Err(e) => {
110+
let _ = tx.send(Err(e.into())).await;
111+
return;
112+
}
111113
Ok(_) => {
112114
let len = partial_output.written().len();
113-
//println!("flush(b={b}) with buffer of size {len}");
114115
let _ = partial_output.into_inner();
115116
buf.resize(len, 0);
116117
if let Err(_) = tx.send(Ok(buf.freeze())).await {
@@ -129,10 +130,12 @@ where {
129130
let mut partial_output = PartialBuffer::new(buf);
130131

131132
match self.finish(&mut partial_output) {
132-
Err(e) => panic!("{e:?}"),
133+
Err(e) => {
134+
let _ = tx.send(Err(e.into())).await;
135+
return;
136+
}
133137
Ok(_) => {
134138
let len = partial_output.written().len();
135-
//println!("finish with buffer of size {}", len);
136139

137140
let mut buf = partial_output.into_inner();
138141
buf.resize(len, 0);

0 commit comments

Comments
 (0)