-
Notifications
You must be signed in to change notification settings - Fork 427
Fix the issue where the 'Shutdown' method fails to properly exit. #255
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
Conversation
""" WalkthroughThe Changes
Possibly related PRs
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
server/sse.go
Outdated
s.mu.RUnlock() | ||
|
||
if srv != nil { | ||
if s.srv != nil { |
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.
Can you explain in the commit message why the read lock was causing the shutdown to not work properly? It is not entirely clear to me.
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.
Ya, same. Unless the issue was that we couldn't get a read lock? But I'm not 100% sure why that would be the case...
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.
FWIW, I think #263 explains why it deadlocks fairly well. Basically, upon Start
being called we do the following:
s.mu.Lock()
defer s.mu.Unlock()
So here in Shutdown()
the s.mu.RUnlock()
deadlocks (because the defer
won't run until Start
exits).
This test demonstrates the deadlock described in mark3labs#254 and mark3labs#263 by running `SSEServer.Start` then `SSEServer.Shutdown`. If it deadlocks, the test fails quickly and reliably, rather than hanging indefinitely. References: - mark3labs#254 - mark3labs#255 - mark3labs#263
FWIW, I created a test in #264 that fails without hte fixes here and passes with them (confirming the fix here). |
@robert-jackson-glean sounds good! Still, a PR description and/or a commit message that's relevant would be ideal for maintenance in the future. |
100% agree! |
This test demonstrates the deadlock described in mark3labs#254 and mark3labs#263 by running `SSEServer.Start` then `SSEServer.Shutdown`. If it deadlocks, the test fails quickly and reliably, rather than hanging indefinitely. References: - mark3labs#254 - mark3labs#255 - mark3labs#263
Summary by CodeRabbit