Skip to content

Building server with several services hangs compiler in rust 1.56 #869

@ricnewton

Description

@ricnewton

Bug Report

Version

Tonic master (commit e78a2d8)

Platform

Reproduced on 64 bit Linux and 64 bit Windows.

Description

We have a tonic based api gateway intended to add a new grpc interface to a large amount of legacy code, we create a tonic server like:

Server::builder()
    .add_service(test_server::TestServer::new(Svc))
    .add_service(test2_server::Test2Server::new(Svc))
    ...
    .serve("127.0.0.1:1339".parse().unwrap());

We currently have on the order of 10-15 services we add, when going from rustc 1.55 to rustc 1.56 the compiler now seems to hang for many minutes.

I have added an integration test shown the issue here: https://github.com/ricnewton/tonic/blob/router_with_many_services/tests/integration_tests/tests/router.rs#L254

When doing

rustup default 1.55
cargo test --test router

The code compiles (though test router_with_35_services fails with a compiler error), when doing

rustup default 1.56
cargo test --test router

The compiler hangs for several minutes.

Is this the correct way to do this many services on tonic? Or is there a better way we should be using?

FYI I also tried the tests on branch port-tonic-router-to-axum and the tests pass there: https://github.com/ricnewton/tonic/blob/axum-router-test/tests/integration_tests/tests/router.rs#L254

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions