-
Notifications
You must be signed in to change notification settings - Fork 67
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
Race Condition with Multiple Stream Methods #3
Comments
Thank you for your detailed issue, a PR would be greatly appreciated! |
tobyvhenderson
added a commit
to tobyvhenderson/signalr_core
that referenced
this issue
Mar 17, 2022
Coventh
added a commit
to Coventh/signalr_core
that referenced
this issue
Nov 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can successfully connect to my server hubs with streaming methods using C# and Typescript clients. However, using this package I get an exception.
Setup
I have two subsequent streaming methods declared:
Outcome
Bad state: Future already completed
" is written to the output stream"
(WebSockets transport) sending data. String data of length 'XXX'.
" messages with the correct lengths), though the messages aren't being passed to the second stream (as it's null).Diagnosis
I've dug/stepped through the code and the error seems to be in
http_connection.dart
. The Future the error message (Bad state: Future already completed
) is complaining about is the_sendBufferedData
one returned at the end of thevoid _bufferData(dynamic data)
method (this can be verified by adding aprint(_sendBufferedData.isCompleted)
statement when using multiple streaming methods. I'm not sure why this is the case (comparing to the TS client code) - but it looks like the buffer is being sent (and that operation not being completed) while other data is being added to the buffer.Fix
The fix is easy... adding a guard around the
_sendBufferedData.complete();
call in the_bufferData
method fixes the issue, ie:...this makes general sense as it means that the
_buffer
actually buffers data until the last buffered contents have been send successfully in the send loop. I'm not sure why that guard isn't in the TS client, though it seems to work without it...I've tested this via Flutter Web and Android and it seems to work.
If you're open to a pull request, I can do that.
The text was updated successfully, but these errors were encountered: