Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(turborepo): Handle unimplemented and failed_precondition in daemon clients #5151

Merged
merged 1 commit into from
May 31, 2023
Merged
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
2 changes: 2 additions & 0 deletions cli/internal/daemon/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ func (c *Connector) sendHello(ctx context.Context, client turbodprotocol.TurbodC
switch status.Code() {
case codes.OK:
return nil
case codes.Unimplemented:
fallthrough // some versions of the rust daemon return Unimplemented rather than FailedPrecondition
case codes.FailedPrecondition:
return ErrVersionMismatch
case codes.Unavailable:
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/daemon/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub enum DaemonError {
impl From<Status> for DaemonError {
fn from(status: Status) -> DaemonError {
match status.code() {
Code::FailedPrecondition => DaemonError::VersionMismatch,
Code::FailedPrecondition | Code::Unimplemented => DaemonError::VersionMismatch,
Code::Unavailable => DaemonError::Unavailable,
c => DaemonError::GrpcFailure(c),
}
Expand Down
9 changes: 7 additions & 2 deletions crates/turborepo-lib/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,13 @@ impl<T: Watcher + Send + 'static> proto::turbod_server::Turbod for DaemonServer<
&self,
request: tonic::Request<proto::HelloRequest>,
) -> Result<tonic::Response<proto::HelloResponse>, tonic::Status> {
if request.into_inner().version != get_version() {
return Err(tonic::Status::unimplemented("version mismatch"));
let client_version = request.into_inner().version;
let server_version = get_version();
if client_version != server_version {
return Err(tonic::Status::failed_precondition(format!(
"version mismatch. Client {} Server {}",
client_version, server_version
)));
} else {
Ok(tonic::Response::new(proto::HelloResponse {}))
}
Expand Down