-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX lts] Fix tag cycles in query parameters #19138
Conversation
f782179
to
2a73dd3
Compare
@pzuraq - Can you review the open issues RE: QP + cycles, and cross link the ones this fixes? |
🙌 #18981 |
We should probably add a QP test for this? |
Yes, absolutely. That was why I was hoping we could cross link the related issues, and create test cases for them... |
I think I have a small repro in twiddle, but maybe not small enough for a test case |
2a73dd3
to
6659046
Compare
Note that there was already a test case, which was passing mistakenly due to the ALLOW_CYCLES logic being faulty. Fixing that logic caused the test to fail, and then the rest of the PR fixed it. Noted this in the original PR description. @rwjblue did link me to a twiddle with an additional failure that somehow was caused by using the |
6659046
to
aa7fa88
Compare
aa7fa88
to
1508fce
Compare
Currently, we wrap query parameters with @dependentKeyCompat manually to ensure they work with the legacy router setup, which watches QPs using observers. When a QP value is labeled as @Tracked, we don't need to replace it with @dependentKeyCompat, but since it's just a plain native getter (from the decorator) we do anyways. This results in a tag cycle being created, which can result in a negative performance impact, as every render pass will be invalidated by the cycle and require a subsequent full revalidation. This bug would have been caught by our ALLOW_CYCLES logic, but that logic was faulty - it was allowing too many cycles, anything that was accessed via get. It should only have allowed cycles from computeds themselves. This PR fixes the bug with ALLOW_CYCLES, and the subsequent bug with @Tracked by only wrapping with @dependentKeyCompat if the value is not @Tracked. It also adds an assertion to prevent users from using @dependentKeyCompat with @computed or @Tracked. Verified that the test failed after fixing ALLOW_CYCLES, and passed again after the fix.
1508fce
to
57a2044
Compare
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.
Rebased on top of all the prettier/eslint changes that just landed on master, and fixed up the error message issue that @chriskrycho pointed out.
Should be good to land once CI is happy...
The bugfix for disallowed cycles in tracked props in #19138 attempted to also narrow the number of cycles that are allowed in general. Cycles should only be allowed for computed property deps, for legacy support reasons. The logic to allow cycles for these tags in particular was mistakenly added to `setup`, which runs on the _prototype_ of the class. This meant that _instance_ computed props were not allowed to have cycles, and this was causing failures in the ecosystem. Added a test that failed and is fixed with this change. I also attempted to create a cycle with `@alias` since it uses a different implementation, but I wasn't able to create one which didn't result in a Maximum Callstack style recursion error, so I think it's just not possible at all anyways, since `@alias` is eager always and never caches.
The bugfix for disallowed cycles in tracked props in #19138 attempted to also narrow the number of cycles that are allowed in general. Cycles should only be allowed for computed property deps, for legacy support reasons. The logic to allow cycles for these tags in particular was mistakenly added to `setup`, which runs on the _prototype_ of the class. This meant that _instance_ computed props were not allowed to have cycles, and this was causing failures in the ecosystem. Added a test that failed and is fixed with this change. I also attempted to create a cycle with `@alias` since it uses a different implementation, but I wasn't able to create one which didn't result in a Maximum Callstack style recursion error, so I think it's just not possible at all anyways, since `@alias` is eager always and never caches.
Does this fix the performance issue that was present when some query params were used alongside tracked properties? |
The bugfix for disallowed cycles in tracked props in #19138 attempted to also narrow the number of cycles that are allowed in general. Cycles should only be allowed for computed property deps, for legacy support reasons. The logic to allow cycles for these tags in particular was mistakenly added to `setup`, which runs on the _prototype_ of the class. This meant that _instance_ computed props were not allowed to have cycles, and this was causing failures in the ecosystem. Added a test that failed and is fixed with this change. I also attempted to create a cycle with `@alias` since it uses a different implementation, but I wasn't able to create one which didn't result in a Maximum Callstack style recursion error, so I think it's just not possible at all anyways, since `@alias` is eager always and never caches. (cherry picked from commit b612d47)
Currently, we wrap query parameters with
@dependentKeyCompat
manuallyto ensure they work with the legacy router setup, which watches QPs
using observers. When a QP value is labeled as
@tracked
, we don't needto replace it with
@dependentKeyCompat
, but since it's just a plainnative getter (from the decorator) we do anyways. This results in a tag
cycle being created, which can result in a negative performance impact,
as every render pass will be invalidated by the cycle and require a
subsequent full revalidation.
This bug would have been caught by our ALLOW_CYCLES logic, but that
logic was faulty - it was allowing too many cycles, anything that was
accessed via
get
. It should only have allowed cycles from computedsthemselves.
This PR fixes the bug with ALLOW_CYCLES, and the subsequent bug with
@tracked
by only wrapping with@dependentKeyCompat
if the value isnot
@tracked
. It also adds an assertion to prevent users from using@dependentKeyCompat
with@computed
or@tracked
.Verified that the test failed after fixing ALLOW_CYCLES, and passed
again after the fix.