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

patch: fx group behavior differs between lists and non-lists #133

Merged

Conversation

denopink
Copy link
Contributor

@denopink denopink commented May 17, 2024

  • the nil value for Cancels []func() group:"cancels,flatten" is discarded by fx (not used during dependency injection)
  • but the nil value for Cancel func() group:"cancels" is used and not discarded
  • currently this triggers panics when a wrp handler returns a nil for Cancel func() group:"cancels"
  • this bug wasn't caught because we weren't returning errors when fx's lifecycle Start/Stop encountered a panic

- the nil value for `Cancels []func() `group:"cancels,flatten"` is discarded by fx (not used during dependency injection)
- but the nil value for `Cancel func() `group:"cancels"` is used and not discarded
- currently this triggers panics when a wrp handler returns a nil for `Cancel func() `group:"cancels"`
- this bug wasn't caught because we weren't returning errors when fx's lifecycle Start/Stop encountered a panic
  - #124 fixes our fx lifecycle
@denopink denopink added the bug Something isn't working label May 17, 2024
@denopink denopink requested review from schmidtw and piccione99 May 17, 2024 03:44
@denopink denopink self-assigned this May 17, 2024
@@ -266,6 +266,10 @@ func onStop(ws *websocket.Websocket, qos *qos.Handler, shutdowner fx.Shutdowner,
ws.Stop()
qos.Stop()
for _, c := range cancels {
Copy link
Contributor Author

@denopink denopink May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently this triggers panics when a wrp handler returns a nil for Cancel func() group:"cancels"

this bug wasn't caught because we weren't returning errors when fx's lifecycle Start/Stop encountered a panic

denopink added a commit that referenced this pull request May 17, 2024
 #133 must be merged first

- Currently if a panic occurs during our fx lifecycle, we log the panic and then ignore it.
- Instead, we want to return an error in order for fx to rollback and shutdown
@schmidtw schmidtw merged commit be05bd5 into main May 17, 2024
14 checks passed
@schmidtw schmidtw deleted the denopink/patch/fx-group-behavior-differs-between-list-nonlist branch May 17, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants