refactor(core): include DI path into cyclic dependency error message#50902
refactor(core): include DI path into cyclic dependency error message#50902JeanMeche wants to merge 7 commits intoangular:mainfrom
Conversation
fb181b7 to
17ac2cc
Compare
17ac2cc to
e879e63
Compare
packages/core/src/render3/di.ts
Outdated
There was a problem hiding this comment.
Is there a better way to retrieve the name of the class ?
There was a problem hiding this comment.
This is also a bit sensitive to the compiler output. It looks like we construct the NodeInjectorFactory in these places:
- In
configureViewWithDirectivewe should be able to capture the name from the directive def. - The two calls in
resolveProvidermight have access to it through the DI token. It's not guaranteed, but we can fall back to something like<unknown>or<anonymous>.
There was a problem hiding this comment.
Are you suggesting something like ?
if(factory.factory.name) {
name = factory.factory.name.slice(0, -8)
} else {
name = 'unknown'
}
There was a problem hiding this comment.
No, I mean that we try to capture the name when constructing the NodeInjectorFactory and then fall back to something like unknown.
e879e63 to
710947e
Compare
00468eb to
539fbb2
Compare
|
@JeanMeche could you please rebase this PR when you get a chance? We'll perform code review and see if we can land it in v17. Thank you. |
539fbb2 to
9649b7a
Compare
9649b7a to
ab10a83
Compare
0cafc1f to
9798e85
Compare
packages/core/src/render3/di.ts
Outdated
There was a problem hiding this comment.
This is also a bit sensitive to the compiler output. It looks like we construct the NodeInjectorFactory in these places:
- In
configureViewWithDirectivewe should be able to capture the name from the directive def. - The two calls in
resolveProvidermight have access to it through the DI token. It's not guaranteed, but we can fall back to something like<unknown>or<anonymous>.
9798e85 to
08efa45
Compare
This commit updates the logic to better handle a situation when there is a cyclic DI dependency detected. Previously, the error message used to contain the name of the token that triggered the problem. With this change, the DI resolution path would also be included, so that it's easier to find and resolve the cycle.
08efa45 to
9432d01
Compare
7fd3fbe to
176e099
Compare
|
TESTED=TGP |
|
This PR was merged into the repository by commit 96014b5. The changes were merged into the following branches: main, 20.1.x |
…50902) This commit updates the logic to better handle a situation when there is a cyclic DI dependency detected. Previously, the error message used to contain the name of the token that triggered the problem. With this change, the DI resolution path would also be included, so that it's easier to find and resolve the cycle. PR Close #50902
This commit updates the logic to better handle a situation when there is a cyclic DI dependency detected. Previously, the error message used to contain the name of the token that triggered the problem. With this change, the DI resolution path would also be included, so that it's easier to find and resolve the cycle.
I'd like to credit @AndrewKushnir who did most of the work on this.
Fixes: #46189