Skip to content

Commit 491c06d

Browse files
committed
chore(backend): Update dependencies to latest
1 parent e8fdcab commit 491c06d

File tree

19 files changed

+755
-832
lines changed

19 files changed

+755
-832
lines changed

Cargo.lock

Lines changed: 679 additions & 748 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rsground-runner = { path = "./backend/runner" }
66

77
actix = "0.13"
88
actix-cors = "0.7.1"
9-
actix_error_proc = { version = "1.1.4", features = ["thiserror"] }
9+
actix_failwrap = { version = "1.0.3" }
1010
actix-rt = { version = "2.10.0", features = ["macros"] }
1111
actix-web = "4"
1212
actix-ws = "0.3.0"
@@ -25,12 +25,12 @@ jsonwebtoken = "8"
2525
lazy_static = "1.4"
2626
log = "0.4"
2727
lsp-types = "0.97.0"
28-
nix = "0.29.0"
28+
nix = {version = "0.29.0", features = ["process", "signal"]}
2929
oauth2 = { version = "4", features = ["reqwest"] }
3030
once_cell = "1.17"
3131
operational-transform = { version = "0.6", features = ["serde"] }
3232
os_pipe = "1.2.1"
33-
reqwest = { version = "0.12.15", features = ["json", "default-tls"] }
33+
reqwest = { version = "0.12.15", default-features = false, features = ["json", "rustls-tls"] }
3434
serde = { version = "1.0", features = ["derive", "rc"] }
3535
serde_json = "1.0"
3636
thiserror = "1.0.63"

backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ uuid.workspace = true
2525
# Http server
2626
actix.workspace = true
2727
actix-cors.workspace = true
28-
actix_error_proc.workspace = true
28+
actix_failwrap.workspace = true
2929
actix-web.workspace = true
3030
actix-ws.workspace = true
3131

backend/runner/src/hakoniwa_ext.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ impl HakoniwaChildExt for Child {
3333
reason: "Life is good".to_owned(),
3434
exit_code: None,
3535
rusage: None,
36+
proc_pid_status: None,
37+
proc_pid_smaps_rollup: None,
3638
}),
3739
Ok(WaitStatus::Signaled(_, signal, _) | WaitStatus::Stopped(_, signal)) => {
3840
Some(ExitStatus {
3941
code: signal as i32,
4042
reason: signal.as_str().to_owned(),
4143
exit_code: None,
4244
rusage: None,
45+
proc_pid_status: None,
46+
proc_pid_smaps_rollup: None,
4347
})
4448
}
4549
Ok(WaitStatus::Continued(_)) => None,
@@ -79,14 +83,16 @@ impl HakoniwaChildExt for Child {
7983
reason: "Aborted".to_owned(),
8084
exit_code: None,
8185
rusage: None,
86+
proc_pid_status: None,
87+
proc_pid_smaps_rollup: None,
8288
};
8389
},
8490
}
8591
}
8692
}
8793
}
8894

89-
pub struct AsyncOsReader(Async<os_pipe::PipeReader>);
95+
pub struct AsyncOsReader(Async<io::PipeReader>);
9096

9197
impl AsyncOsReader {
9298
/// N is the buffer size for reads
@@ -103,8 +109,8 @@ impl AsyncOsReader {
103109
}
104110
}
105111

106-
impl From<os_pipe::PipeReader> for AsyncOsReader {
107-
fn from(value: os_pipe::PipeReader) -> Self {
112+
impl From<io::PipeReader> for AsyncOsReader {
113+
fn from(value: io::PipeReader) -> Self {
108114
Self(Async::new(value).expect("Cannot create async wrapper"))
109115
}
110116
}
@@ -116,7 +122,7 @@ impl AsFd for AsyncOsReader {
116122
}
117123

118124
impl ops::Deref for AsyncOsReader {
119-
type Target = os_pipe::PipeReader;
125+
type Target = io::PipeReader;
120126

121127
fn deref(&self) -> &Self::Target {
122128
&self.0.get_ref()
@@ -163,19 +169,19 @@ impl<const N: usize> Stream for AsyncOsReaderStream<N> {
163169
}
164170

165171
pub struct LspStdoutReader {
166-
inner: Async<os_pipe::PipeReader>,
172+
inner: Async<io::PipeReader>,
167173
filled: usize,
168174
buf: Option<Vec<u8>>,
169175
}
170176

171177
impl LspStdoutReader {
172-
fn inner(&self) -> &Async<os_pipe::PipeReader> {
178+
fn inner(&self) -> &Async<io::PipeReader> {
173179
&self.inner
174180
}
175181
}
176182

177-
impl From<os_pipe::PipeReader> for LspStdoutReader {
178-
fn from(value: os_pipe::PipeReader) -> Self {
183+
impl From<io::PipeReader> for LspStdoutReader {
184+
fn from(value: io::PipeReader) -> Self {
179185
Self {
180186
inner: Async::new(value).expect("Cannot create async wrapper"),
181187
filled: 0,
@@ -191,7 +197,7 @@ impl AsFd for LspStdoutReader {
191197
}
192198

193199
impl ops::Deref for LspStdoutReader {
194-
type Target = os_pipe::PipeReader;
200+
type Target = io::PipeReader;
195201

196202
fn deref(&self) -> &Self::Target {
197203
&self.inner().get_ref()

backend/runner/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use futures::TryStreamExt;
99
use futures_ext::{FutureExt, OptionalFuture};
1010
use hakoniwa::{Child, Command, Container, ExitStatus, Output};
1111
use hakoniwa_ext::{AsyncOsReader, HakoniwaChildExt};
12-
pub use os_pipe::{PipeReader, PipeWriter};
1312
use std::future::Future;
13+
pub use std::io::{PipeReader, PipeWriter};
1414
use std::path::{Path, PathBuf};
1515
use tokio::sync::oneshot;
1616
use tokio::{fs, io};
@@ -46,6 +46,7 @@ impl Runner {
4646
Container::new()
4747
.hostname("rsground")
4848
.rootfs(concat!(env!("CARGO_MANIFEST_DIR"), "/lxc_rootfs"))
49+
.expect("Cannot create container")
4950
.tmpfsmount("/tmp")
5051
.devfsmount("/dev")
5152
.procfsmount("/proc")
@@ -171,9 +172,12 @@ impl Runner {
171172
};
172173

173174
let (status, stdout, stderr) =
174-
tokio::try_join!(status, stdout, stderr).map_err(|join_error| {
175-
return hakoniwa::Error::Unexpected(format!("Join error: {join_error}"));
176-
})?;
175+
tokio::try_join!(status, stdout, stderr).unwrap_or_else(|join_error| {
176+
eprintln!("Join error: {join_error}");
177+
// FIXME: hakoniwa errors are obscured. see https://github.com/souk4711/hakoniwa/issues/107
178+
// Wait until next release.
179+
panic!("tokio task panicked. see https://github.com/souk4711/hakoniwa/issues/107")
180+
});
177181

178182
Ok((status, stdout, stderr))
179183
}

backend/src/auth/routes.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use actix_error_proc::{proof_route, HttpResult};
2-
use actix_web::{get, web, HttpRequest, HttpResponse, Responder};
1+
use actix_failwrap::proof_route;
2+
use actix_web::{HttpRequest, HttpResponse, get, web};
33
use oauth2::{AuthorizationCode, CsrfToken, Scope, TokenResponse};
44
use serde::Deserialize;
55
use uuid::Uuid;
@@ -22,7 +22,7 @@ pub struct AuthRequest {
2222
}
2323

2424
#[get("/auth")]
25-
pub async fn auth(oauth: web::Data<OAuthData>) -> impl Responder {
25+
pub async fn auth(oauth: web::Data<OAuthData>) -> HttpResponse {
2626
let (auth_url, _csrf_token) = oauth
2727
.client
2828
.authorize_url(CsrfToken::new_random)
@@ -34,19 +34,19 @@ pub async fn auth(oauth: web::Data<OAuthData>) -> impl Responder {
3434
.finish()
3535
}
3636

37-
#[get("/auth/me")]
38-
pub async fn me(req: HttpRequest) -> HttpResult<HttpErrors> {
37+
#[proof_route("GET /auth/me")]
38+
pub async fn me(req: HttpRequest) -> Result<HttpResponse, HttpErrors> {
3939
let user_info = jwt::get_user_info(&req)?;
4040

4141
Ok(HttpResponse::Ok().json(user_info))
4242
}
4343

44-
#[get("/auth/callback")]
44+
#[proof_route("GET /auth/callback")]
4545
async fn callback(
4646
state: web::Data<AppState>,
4747
query: web::Query<AuthRequest>,
4848
oauth_data: web::Data<OAuthData>,
49-
) -> HttpResult<HttpErrors> {
49+
) -> Result<HttpResponse, HttpErrors> {
5050
let code = AuthorizationCode::new(query.code.clone());
5151

5252
let token = oauth_data
@@ -90,11 +90,11 @@ struct GuestLoginRequest {
9090
guest_name: String,
9191
}
9292

93-
#[proof_route(post("/auth/guest"))]
93+
#[proof_route("POST /auth/guest")]
9494
async fn login_guest(
9595
state: web::Data<AppState>,
9696
body: web::Json<GuestLoginRequest>,
97-
) -> HttpResult<HttpErrors> {
97+
) -> Result<HttpResponse, HttpErrors> {
9898
let guest_name = &body.guest_name;
9999
let guest_uuid = Uuid::new_v4().to_string();
100100

@@ -122,12 +122,12 @@ struct UpdateNameRequest {
122122
new_name: ArcStr,
123123
}
124124

125-
#[proof_route(post("/auth/update"))]
125+
#[proof_route("POST /auth/update")]
126126
async fn update_name(
127127
state: web::Data<AppState>,
128128
body: web::Json<UpdateNameRequest>,
129129
req: actix_web::HttpRequest,
130-
) -> HttpResult<HttpErrors> {
130+
) -> Result<HttpResponse, HttpErrors> {
131131
let token_data = jwt::get_user_info(&req)?;
132132

133133
if !token_data.is_guest {

backend/src/collab/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::Serialize;
55
use tokio::sync::{Notify, RwLock, RwLockWriteGuard};
66

77
use crate::collab::ot::transform_index;
8-
use crate::utils::{define_local_logger, ArcStr, AsyncInto};
8+
use crate::utils::{ArcStr, AsyncInto, define_local_logger};
99

1010
use super::UserOperation;
1111

backend/src/health.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use actix_web::{get, HttpResponse};
1+
use actix_web::{HttpResponse, get};
22

33
#[get("/health")]
44
pub async fn health() -> HttpResponse {

backend/src/http_errors.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use actix_error_proc::ActixError;
1+
use actix_failwrap::ErrorResponse;
22
use thiserror::Error;
33

4-
#[derive(ActixError, Error, Debug)]
4+
#[derive(ErrorResponse, Error, Debug)]
55
pub enum HttpErrors {
66
// -- JWT/Auth related -- //
77
#[error("Error encoding JWT: {0}")]
@@ -12,31 +12,31 @@ pub enum HttpErrors {
1212
CodeExchange(String),
1313

1414
#[error("Only guest users can change their name")]
15-
#[http_status(Forbidden)]
15+
#[status_code(Forbidden)]
1616
GithubNameChange,
1717

1818
#[error("Error fetching github user: {0}")]
1919
GithubUserFetch(reqwest::Error),
2020

2121
#[error("Invalid token")]
22-
#[http_status(Unauthorized)]
22+
#[status_code(Unauthorized)]
2323
InvalidJWT,
2424

2525
#[error("No token provided")]
26-
#[http_status(Unauthorized)]
26+
#[status_code(Unauthorized)]
2727
NoTokenProvided,
2828

2929
// -- Websockets related -- //
3030
#[error("Project doesn't exist")]
31-
#[http_status(NotFound)]
31+
#[status_code(NotFound)]
3232
ProjectDoesNotExist,
3333

3434
#[error("Do not have access to project")]
35-
#[http_status(Unauthorized)]
35+
#[status_code(Unauthorized)]
3636
NotAccessible,
3737

3838
#[error("Invalid password for private project")]
39-
#[http_status(Unauthorized)]
39+
#[status_code(Unauthorized)]
4040
InvalidPassword,
4141

4242
#[error("Error at websocket start: {0}")]

backend/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::collections::HashMap;
1111
use std::sync::LazyLock;
1212

1313
use actix_cors::Cors;
14-
use actix_web::{web, App, HttpServer};
14+
use actix_web::{App, HttpServer, web};
1515

1616
use auth::github;
1717
use auth::jwt::JWT_SECRET;

0 commit comments

Comments
 (0)