You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
fx.OnStart is not able to resolve my *net.TCPListener dependency in the expected way. It does work in an unexpected way, see below for explanation.
To Reproduce
Let's consider the example below for a webserver module.
Hooks passed as OnStart hooks are not allowed to take dependencies outside of the provider's direct dependencies or result types.
See: https://pkg.go.dev/go.uber.org/fx#OnStart:
"The hook function passed into OnStart cannot take any arguments outside of the annotated constructor's existing dependencies or results, except a context.Context."
I'm pretty sure this used to work in the past since I THINK I've written this code before.
That was actually an unintentional effect of a bug that was fixed in #983.
That explains it then, thank you for the clear response. I guess a more clear error would be better (it could be detected that a requested dependency is invalid) but since it is already documented I guess this can also be closed.
Describe the bug
fx.OnStart is not able to resolve my *net.TCPListener dependency in the expected way. It does work in an unexpected way, see below for explanation.
To Reproduce
Let's consider the example below for a webserver module.
Given a test file like this:
Running
go test
will result in an error like this:But, if I change the signature of the New function, like this:
It will work.
Expected behavior
I would expect the first setup above to work without missing dependency error.
Additional context
I'm pretty sure this used to work in the past since I THINK I've written this code before.
The text was updated successfully, but these errors were encountered: