-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[🐞] Computed unmount & component unmount race condition issue #5203
Comments
This is still a pretty complicated repro. Please create something simpler next time.... I took a look at the current repro, and it really needs to be simplified further if you think this is a real issue. So I don't think this is an issue with Qwik, as there is no code path which would prevent the rendering of a new content before the data is available from the server. The issue is that So to me this is working as intended. What do you think? Can we close the issue? |
Nope:) Take a look at this file, https://github.com/Kasheftin/qwik-unmount-computed-bug2/blob/master/src/routes/index.tsx render(input) {
if (input.type === 'first') {
.. render first and pass input.data there knowing that it has FirstData type
} else if (input.type === 'second') {
.. render second and pass input.data there knowing that it has SecondData type
}
} However, the second click on a different button throws an error. The reason is https://github.com/Kasheftin/qwik-unmount-computed-bug2/blob/master/src/components/FirstComponent.tsx has |
Ohh I see... That is much better repro (importance of minimal repros) Yes, the parent component should tear down the component before the |
I made the repro into a playground for easier inspection. Indeed, the problem is always the same, signals propagate out of tree order. I'm thinking the solution is to record the tree depth when registering listeners, and running listeners sorted by increasing depth. If we make sure to honor listener removal, that should fix the problem. There might still be issues with components that emit promises in their templates though. Right @mhevery ? |
Yes, I think that would be a great fix! |
Hey guys, has there been any movement on this? i'm experiencing another issue where a
This should be a P3 issue |
I am also facing this issue. @wmertens , is it a simple fix? |
@sarat1669 I believe this should be fixed when Qwik V2 is released, i'm not sure how long that could be but the team are working hard on it |
I tried this code with v2 and it's still failing |
Which component is affected?
Qwik Runtime
Describe the bug
This bug is about the incorrect order of evaluation/unmounting computed variables and unmounting the component itself.
Suppose, we have a dynamic route
[...path]
which loads different components depending on thepath
variable. Then, the global store is populated with different data depending on thepath
.The minimal demo app has the following store:
Basically,
loadStore
provides a connected pair of{ data, dataType }
: ifdataType
isDataType.first
, thendata
hasFirstData
type, else ifdataType
isDataType.second
, thendata
hasSecondData
type. It's far from typescript best practice, but technically it's totally fine.[...path]/index.tsx
file just loads different page component depending on thedataType
:Finally, the page component heavily relies on the
data
type:FirstPage
expectsdata
to haveFirstData
type. Since<FirstPage>
is being shown only whendataType
isDataType.first
, it's natural to expect thatstore.data
hasFirstData
type:It seems to be a valid code. When the route changes,
{ data, dataType }
pair is substituted into the store in one tick. IfdataType
changes, it should unmount the previous page and mount the new page.However, there's something wrong with unmounting logic. When the page changes, it tries to evaluate
useComputed$
for the old page using the new data before unmounting this old page. It should somehow know that the component is going to be unmounted and skip evaluating computeds.Reproduction
https://github.com/Kasheftin/qwik-unmount-computed-bug
Steps to reproduce
npm run dev
ornpm run preview
Cannot read properties of undefined
error appearsSystem Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: