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
Issue 7084 - fix the compiler's "is recursive" check #8705
Conversation
@@ -128,6 +128,11 @@ export class RuntimeCompiler implements ComponentResolver { | |||
var childViewPipes: CompilePipeMetadata[] = | |||
this._metadataResolver.getViewPipesMetadata(dep.comp.type.runtime); | |||
var childIsRecursive = ListWrapper.contains(childCompilingComponentsPath, childCacheKey); | |||
ListWrapper.forEachWithIndex(childViewDirectives.map(x => x.type.runtime), descendant => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forEachWithIndex
-> forEach
however childViewDirectives.map().forEach(...)
should work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicb: whoops, thanks, fair point.
Here is the test I'd made based on the original issue (feedback welcome), though I wasn't very sure what might be the best place for it:
I guess I'll squash them into one when the test is in as well. |
This should go into The test looks good, but please add a bit more description than just the issue number. |
6fc7083
to
84fd965
Compare
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
84fd965
to
936dc00
Compare
CLAs look good, thanks! |
@tbosch: I added the test, vicb's suggestion, and squashed. CI failed on build though... what could I do about that? |
tcb.createAsync(FakeRecursiveComp) | ||
.then((fixture) => { | ||
fixture.detectChanges(); | ||
expect(fixture.nativeElement).toHaveText('[]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a bit more expectations to see that the child components really work.
Sorry, master moved ahead, you need to rebase. |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
50500ff
to
d31058f
Compare
Um, I tried merging in anything newer, then rebasing everything but the original commit out again in my issue branch. I don't see that reflected here yet, but I'm not sure if that was as you'd intended it. |
Somehow you got a lot of commits into the PR. You should only have one that contains the changes you would like to make... You can try doing a:
|
d31058f
to
d9b2ec8
Compare
CLAs look good, thanks! |
d9b2ec8
to
927f6a5
Compare
@@ -116,6 +116,11 @@ export class RuntimeCompiler implements ComponentResolver { | |||
var childViewPipes: CompilePipeMetadata[] = | |||
this._metadataResolver.getViewPipesMetadata(dep.comp.type.runtime); | |||
var childIsRecursive = ListWrapper.contains(childCompilingComponentsPath, childCacheKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
var childIsRecursive = childCompilingComponentsPath.indexOf(childCacheKey) > -1 || childViewDirectives.some(dir => childCompilingComponentsPath.indexOf(dir.type.runtime) > -1);
f832dc9
to
15fb42d
Compare
Fix how the compiler checks for recursive components by also considering component descendants. Previously, it only checked if the current component was evaluated previously. This failed in certain cases of mutually recursive components, causing `createAsync` in tests to not resolve. closes [7084](angular#7084)
Thanks for the advice to both. |
This fix prevented waiting for child components even if the cycle was only introduced via the `directives` array, i.e. without actually having a cycle. This easily causes issues for applications that have one shared list of directives for all components. This reverts commit 3d5bb23.
Hi, I had to revert this commit, see #9647 |
This fix prevented waiting for child components even if the cycle was only introduced via the `directives` array, i.e. without actually having a cycle. This easily causes issues for applications that have one shared list of directives for all components. This reverts commit 3d5bb23.
See #9594 for a better fix. |
No problem, I'll have to admit it was hard for me to foresee all potential implications. It does make me curious though, since I hadn't really experienced issues with it yet (from monkey-patching to test). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Please check if the PR fulfills these requirements
I'm not sure if there's much to add in terms of documentation for this fix. Feel free to correct.
I've written a test (based on the Plunker reproduction in the original issue), but I don't see a spec file for the
runtime_compiler
anymore. Moreover, I don't think my reproduction really qualifies as a compiler unit test, since it's a bit bigger in scope. So I'm not quite sure where you guys would prefer to have me put it -- I'd be glad to get some feedback on this then add it in as desired.What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
See 7084: the compiler currently judges some mutually recursive component structures as non-recursive, which causes it to await non-resolving promises. As a result, in production it hangs without errors, in tests,
createAsync
just times out to Jasmine.What is the new behavior?
I let the compiler check the current component's descendants as well, so as to reclassify the misjudged cases as recursive. This way, it no longer hangs/errors.
Does this PR introduce a breaking change?
Other information:
From what I can see, the offline compiler has no similar check. I also haven't found equivalent Dart code.
Note I have not yet re-run the test as asked in the guidelines. Like for some other non-Mac users (environment: Windows 10 + Vagrant Ubuntu VM that break on symlinks), building and running the test suite has proven a major barrier for me. I apologize for this, and hope Travis will do for now.