-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[bug] Write sends every second message #557
Comments
It's unlikely that the issue is with this package because the data is written to the operating system before If you have not already done so, run the application with the race detector. The code in the issue is suspect. After the connection fails, the write loop will spin forever receiving and discarding values from |
Sorry hadn't much experience with go routines yet. How do I test if any zombie routines are running if I may ask? Unless this is a part of the race detector which I'm currently trying to implement as you proposed. |
Sorry for duplicate message. But I thought it should be mentioned. It's always the 2nd message that is send. No matter the delay between the messages. It feels so robust that it's like there is a condition where it says "if it's not the second message, dont send this" (which yes of course that would be ridiculous hahaha, but I hope you get what I mean by this). It doesn't feel like it's a race issue. Usually in race issues the delay matters afaik. Here it doesn't. It's always the 2nd message that is send. Unless I'm not getting this right. |
You will see output from the Fix the goroutine by replacing the call to conn.Close() with a break statement or a return statement. Are two goroutines receiving from It only takes a minute to run the race detector (build with the -race flag and run). Highly recommend given that you are new goroutines. |
What do you mean by that? What part of my call should I replace? :) It already has
The only goroutine that is receiving from eventChannel is this one described in the post
Where will the output appear? It seems like there is no feedback on the compilation, I dont know if I should expect it in the runtime or something. :) |
Find the statement
The |
I tried
I did that. You're right, I shouldn't have called |
I don't have any more suggestions on how to debug the application. There is insufficient information debug reproduce the problem. Hopefully somebody else will chime in. |
@srybacki I dont know if this might be of use, but this is the repository file in the repository that hosts the whole app. I dont know if I missed any necessary information regarding this issue in particular, but pardon me if I missed any significant debugging info. |
There's a data race. Two goroutines write concurrently to the connection with no synchronization between them. Fix by running a single goroutine with a Multiple goroutines can receive on There are other issues with the application, but that's outside the scope of the websocket package. This issue can be closed. |
Yes, I think I get it now. Obviously the event is sent only once to one subscriber and it's not broadcasted to all of them. So I'll just have to make an array of channels in that case for each subscriber. edit: And yes you are correct. The deeper I go from now on, the more issues I find with the application regarding its event-websocket nature and mechanics. Thanks for your feedback! You helped much. Thanks for your time and effort. |
Describe the bug
WriteJSON/WriteMessage (didnt try others) writea response every second loop. But there are no signs of errors, and it just keeps doing the same thing.
The most strange thing, is that
conn.WriteJSON
/conn.WriteMessage
seem to be called everytime! But the message seems to not reach the final light of the tunnel ...…
Versions
…
Steps to Reproduce
Try to replicate the code snippet bellow I guess? Sorry, if I'm not being helpful here. But it seems like my bug is just
conn.WriteJSON
or whatever write functin there is. I dont know if that goes further than that.…
Expected behavior
Write
functions are supposed write every single message they are told to send, not every second one.…
Code Snippets
…
The text was updated successfully, but these errors were encountered: