Open frederikhors opened 3 years ago
@timostamm just answered:
For server streaming, the response is read in chunks. The server must send the response chunks out as soon as possible, not wait for the response to finish.
XMLHttpRequest has a limitation, the only way for clients to read the response as chunks is to use a text-based format. That's why grpc-web has the text format.
It is possible that the libraries you are using have better support for the text format. I guess the chance is rather slim though. It is more likely that the authboss middleware is just not written with streaming responses in mind.
@aarondl can you please help me here? 🙏
Hi there @frederikhors. Not sure how to help here, it's not built that way.
it's not built that way.
What do you mean?
Why is the response not closed?
The response is always closed, it's a guarantee by the stdlib nowadays. Now because you're using grpc in some fashion that might be different maybe they're doing their own weird http things.
Authboss's middleware is pretty simple, when a request comes in it gives the request to LoadClientState which gives it to your ClientStateReadWriter
to extract client state variables out. It collects session and cookie changes in memory and when someone calls WriteHeader or Write it will flush those out to the response. In essence that's how it works. I'm not sure exactly where things are going wrong here because there's quite a few layers.
But I'd suggest reading client_state.go and take a look at the ClientStateResponseWriter
which is likely the trouble spot. Notably calls to hijack() will fail completely and if they're using hijack that might be a problem?
See the answer from @johanbrandhorst here:
Sounds like some sort of timeout is being hit. I don't know why the middleware is causing the server to wait, I can't see it doing anything suspicious with the request body at a first glance. I'd probably just try and debug it more!
I'll report your answer to his amazing team.
I have been using authboss for a long time (it's such a pleasure, THANKS!).
I'm using it with a grpc-web server too.
Today I had to test the gRPC server streaming and after HOURS of trying I realized that it is authboss that causes a strange issue described below:
I'm trying to use protobuf-ts but I don't get messages from server until connection is closed.
I'm using Svelte 3 like this:
The call in in pending state for about 2.2 min. After that I get all messages logged in console.
If I change this line:
to:
(removing
authb.LoadClientStateMiddleware
) it works!Why?
@aarondl, this is HUGE! Can you please help me solve it?