Skip to content
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

Fix graceful shutdown #2603

Merged
merged 1 commit into from
Jul 6, 2020
Merged

Fix graceful shutdown #2603

merged 1 commit into from
Jul 6, 2020

Conversation

shunyy
Copy link
Contributor

@shunyy shunyy commented Jul 5, 2020

Fixed invalid context value passing to context.WithTimeout for graceful-shutdown.

Current generated example of graceful-shutdown is calling context.WithTimeout with already closed context, because of that server shutdown immediately. I don't think it is intentional behavior, so fixed with passing context.Background to context.WithTimeout

explanation

<-ctx.Done() // Closed!!

ctx, cancel := context.WithTimeout(ctx, 30*time.Second) // already closed ctx 😢 
defer cancel()

srv.Shutdown(ctx) // does not wait for timeout as intended

changes to examples can be reviewed in: goadesign/examples#71

@raphael
Copy link
Member

raphael commented Jul 6, 2020

Whoops, thank you so much! great catch.

@raphael raphael merged commit e7a9740 into goadesign:v3 Jul 6, 2020
@raphael
Copy link
Member

raphael commented Jul 6, 2020

Would you mind back-porting this fix to v2 please? simply cherry-pick the merge commit - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants