-
Notifications
You must be signed in to change notification settings - Fork 40
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
(WIP) remove ClientHello
from the client creation path
#2387
base: main
Are you sure you want to change the base?
Conversation
with pytest.raises(ConnectionError): | ||
client_from_env("https://foo.invalid", credentials) | ||
|
||
# Make sure later clients can still succeed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relied on a bit of a questionable behavior where a failing ClientHello
would cause the singleton to not register. Now that we're removing ClientHello
from Client.from_env
, we don't catch the connection error in a way that resets the singleton, which means we leak it into the rest of the function.
I think this is a bit silly – I think it should be safe to assume that Client.from_env
always creates one single unified client based on the environment.
We have an auto-fixture to reset the client singleton so splitting it in to two tests resolve this state leakage.
ClientHello
from the client creation pathClientHello
from the client creation path
Super strange test failure. It seems like there is some side-effect to running hello() which then affects the later calls to It's probably not the end of the world to skip these assertions, since they are mostly for making sure we warn if we accidentally use the anti-pattern of calling our API stubs from outside of the synchronicity event loop (since that would break the cancellation context which is event-loop specific). In a way the exception makes sense, and I'm not actually 100% sure how the test passed before this... Will look a bit more |
Ok, the issue stems from Now that |
Ahhh, All in all pretty bad that we even allow usage of the client's API stub across event loops - considering the amount of foot guns it exposes I think we might want to just raise an exception when that happens and expect all of the SDK + tests to only use the Client + api stub from a single event loop. |
This should reduce the e2e latency of running ephemeral apps by about 100-250ms. It removes two server round trips sitting in the critical path (one locally, one in the container). It also simplifies the RPC protocol a bit, which seems useful (like if we want to add support for other languages).
Instead of relying on
ClientHello
to catch various connection issues, we now rely on any request.TODO: This makes it slightly harder to print helpful things like "your client version is too old", which is I think the only real drawback here. I'll think about ways we can do this using other RPCs instead. However this might require moving a bunch of server code from the
ClientHello
method into the middleware.