Revert "chore: Bump async-tungstenite to 0.23 (and tungstenite to 0.20.1) (#15039)" (#15048)

This reverts commit 4d65f7eea3.

Reverting because it causes auth with collab to break.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-23 18:22:37 -04:00 committed by GitHub
parent 855048041d
commit 6769e55ce0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 30 deletions

58
Cargo.lock generated
View file

@ -661,6 +661,18 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "async-native-tls"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e9e7a929bd34c68a82d58a4de7f86fffdaf97fb2af850162a7bb19dd7269b33"
dependencies = [
"async-std",
"native-tls",
"thiserror",
"url",
]
[[package]]
name = "async-native-tls"
version = "0.5.0"
@ -864,17 +876,17 @@ dependencies = [
[[package]]
name = "async-tungstenite"
version = "0.23.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1e9efbe14612da0a19fb983059a0b621e9cf6225d7018ecab4f9988215540dc"
checksum = "5682ea0913e5c20780fe5785abacb85a411e7437bf52a1bedb93ddb3972cb8dd"
dependencies = [
"async-native-tls",
"async-native-tls 0.3.3",
"async-std",
"futures-io",
"futures-util",
"log",
"pin-project-lite",
"tungstenite",
"tungstenite 0.16.0",
]
[[package]]
@ -2304,7 +2316,7 @@ name = "client"
version = "0.1.0"
dependencies = [
"anyhow",
"async-native-tls",
"async-native-tls 0.5.0",
"async-recursion 0.3.2",
"async-tungstenite",
"chrono",
@ -9627,6 +9639,19 @@ dependencies = [
"workspace",
]
[[package]]
name = "sha-1"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpufeatures",
"digest 0.9.0",
"opaque-debug",
]
[[package]]
name = "sha1"
version = "0.10.6"
@ -11195,7 +11220,7 @@ dependencies = [
"futures-util",
"log",
"tokio",
"tungstenite",
"tungstenite 0.20.1",
]
[[package]]
@ -11668,6 +11693,26 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8"
[[package]]
name = "tungstenite"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ad3713a14ae247f22a728a0456a545df14acf3867f905adff84be99e23b3ad1"
dependencies = [
"base64 0.13.1",
"byteorder",
"bytes 1.5.0",
"http 0.2.9",
"httparse",
"log",
"native-tls",
"rand 0.8.5",
"sha-1",
"thiserror",
"url",
"utf-8",
]
[[package]]
name = "tungstenite"
version = "0.20.1"
@ -11680,7 +11725,6 @@ dependencies = [
"http 0.2.9",
"httparse",
"log",
"native-tls",
"rand 0.8.5",
"sha1",
"thiserror",

View file

@ -167,7 +167,6 @@ assets = { path = "crates/assets" }
assistant = { path = "crates/assistant" }
assistant_slash_command = { path = "crates/assistant_slash_command" }
assistant_tooling = { path = "crates/assistant_tooling" }
async-tungstenite = { version = "0.23" }
audio = { path = "crates/audio" }
auto_update = { path = "crates/auto_update" }
breadcrumbs = { path = "crates/breadcrumbs" }
@ -296,6 +295,7 @@ async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "8
async-recursion = "1.0.0"
async-tar = "0.4.2"
async-trait = "0.1"
async-tungstenite = { version = "0.16" }
async-watch = "0.3.1"
async_zip = { version = "0.0.17", features = ["deflate", "deflate64"] }
base64 = "0.13"

View file

@ -12,7 +12,7 @@ use crate::{
executor::Executor,
AppState, Error, RateLimit, RateLimiter, Result,
};
use anyhow::{anyhow, bail, Context as _};
use anyhow::{anyhow, Context as _};
use async_tungstenite::tungstenite::{
protocol::CloseFrame as TungsteniteCloseFrame, Message as TungsteniteMessage,
};
@ -1392,13 +1392,7 @@ pub async fn handle_websocket_request(
let socket = socket
.map_ok(to_tungstenite_message)
.err_into()
.with(|message| async move {
if let Some(message) = to_axum_message(message) {
Ok(message)
} else {
bail!("Could not convert a tungstenite message to axum message");
}
});
.with(|message| async move { Ok(to_axum_message(message)) });
let connection = Connection::new(Box::pin(socket));
async move {
server
@ -5160,21 +5154,16 @@ async fn get_private_user_info(
Ok(())
}
fn to_axum_message(message: TungsteniteMessage) -> Option<AxumMessage> {
fn to_axum_message(message: TungsteniteMessage) -> AxumMessage {
match message {
TungsteniteMessage::Text(payload) => Some(AxumMessage::Text(payload)),
TungsteniteMessage::Binary(payload) => Some(AxumMessage::Binary(payload)),
TungsteniteMessage::Ping(payload) => Some(AxumMessage::Ping(payload)),
TungsteniteMessage::Pong(payload) => Some(AxumMessage::Pong(payload)),
TungsteniteMessage::Close(frame) => {
Some(AxumMessage::Close(frame.map(|frame| AxumCloseFrame {
TungsteniteMessage::Text(payload) => AxumMessage::Text(payload),
TungsteniteMessage::Binary(payload) => AxumMessage::Binary(payload),
TungsteniteMessage::Ping(payload) => AxumMessage::Ping(payload),
TungsteniteMessage::Pong(payload) => AxumMessage::Pong(payload),
TungsteniteMessage::Close(frame) => AxumMessage::Close(frame.map(|frame| AxumCloseFrame {
code: frame.code.into(),
reason: frame.reason,
})))
}
// we can ignore `Frame` frames as recommended by the tungstenite maintainers
// https://github.com/snapview/tungstenite-rs/issues/268
TungsteniteMessage::Frame(_) => None,
})),
}
}