Skip to content

rpc::Disconnector does not wait for clean shutdownΒ #583

@dwrensha

Description

@dwrensha

The documentation of get_disconnector() seems to imply that the Disconnector future will wait until the RpcSystem's connection is cleanly shut down:

/// Returns a `Disconnector` future that can be run to cleanly close the connection to this `RpcSystem`'s network.
/// You should get the `Disconnector` before you spawn the `RpcSystem`.
pub fn get_disconnector(&self) -> rpc::Disconnector<VatId> {
rpc::Disconnector::new(self.connection_state.clone())
}

However, the actual logic just calls ConnectionState::disconnect()

state.disconnect(::capnp::Error::disconnected(
"client requested disconnect".to_owned(),
));
and does not wait on the future that actually performs shutdown():
let promise = c.shutdown(Err(error)).then(|r| match r {
Ok(()) => Promise::ok(()),
Err(e) => {
if e.kind != ::capnp::ErrorKind::Disconnected {
// Don't report disconnects as an error.
Promise::err(e)
} else {
Promise::ok(())
}
}
});
let Some(fulfiller) = self.disconnect_fulfiller.borrow_mut().take() else {
unreachable!()
};
let _ = fulfiller.send(Promise::from_future(promise.attach(c)));

This means that the Disconnector future will not report any errors from the shutdown, and indeed will probably resolve before the actual shutdown completes. This is contrary to the documentation noted above, and go against what I would expect from asynchronous disconnect, even without reading the documentation.

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