-
-
Notifications
You must be signed in to change notification settings - Fork 109
fix(runtime-vapor): detach effect scope & component instance #174
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
Conversation
✅ Deploy Preview for vapor-repl ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for vapor-template-explorer ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Size ReportBundles
Usages
|
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.
LGTM. But could you please add unit tests for it?
Added unit tests to the critical path that triggered the bug. |
b6bde54
to
5a599d6
Compare
The existing
setCurrentInstance
will setinstance.scope.on()
internally andinstance.scope.off()
when calling reset, but as an internal Function, this hidden behavior is not very intuitive, and there are two problems:effectScope.on
cannot handle nested recursive calls to itself, because the internalprevScope
can only store one value.currentInstance
need to setinstance.scope.on()
at the same time, and this behavior is wrong inrenderEffect
.So this PR removes
instance.scope.on()
insetCurrentInstance
.I initially started investigating this issue because of the following bug.
Bug Playground
In this example, try entering text.
There won't be any problem if just adding texts, once the the pe-existing texts get deleted, it will cause the call to
setText
to fail.This is because when the
v-for
element get unmounted, theeffect.onStop()
that does not belong to thev-for
element would be mistakenly called. This is caused by the combined problems with problem "1" and "2" mentioned above.