-
Notifications
You must be signed in to change notification settings - Fork 124
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
DI: Module provider visibility issue #596
Comments
The bug in the code here comes from a misunderstanding. Encapsulated services like class AuthenticationListener {
@eventDispatcher.listen(httpWorkflow.onAuth)
onServerMainBootstrap(event: typeof httpWorkflow.onAuth.event, module: AppModule) {
event.injectorContext.set(
SessionForRequest,
new SessionForRequest(
'sidValue',
'uidValue',
),
module,
);
}
} this way the DI container can find the SessionForRequest and set it correctly. |
Thanks for the explanation, it makes sense now. I didn't expect event injection context to be root context instead of the listener's module context. |
This probably needs to be documented in some way |
@marcj Unfortunately, the suggested fix didn't help: https://github.com/deepkit/deepkit-framework/pull/595/files#diff-5a1f8db1e5e23da96c85177fe8129b79e23bf0a80af0053c5407237aa2c1594bR8, result is the same: |
Here's the injector that gets built for
|
the fix did help, I tested it locally. I guess you have a new use-case/different code now. the error message indicates that the setter isn't working (maybe injected "module" is wrong), but I haven't looked closely yet. |
Please refer to the PR with a failing test case: https://github.com/deepkit/deepkit-framework/pull/595/files Use case is the same. Injector wants to resolve value from some other module, because
|
@alpharder is this issue still present? |
I've created a PR with a failing test case: https://github.com/deepkit/deepkit-framework/pull/595/files#diff-8638469975c860d179cea016ca3ee1f3c2d65fbd6eba97a2096def06beeaa332R193
TL;DR is provider registered within a deeply nested module isn't available for ingestion within the same module, unless this module gets exported to the root.
The text was updated successfully, but these errors were encountered: