Repository navigation
Fix scope stack staying broken after a yield in strict mode - #105
Conversation
|
I have concerns with cancelling the thread:
I'd be satisfied with just emitting a warn (print if running in a vanilla Luau environment) if a yield is detected. I don't think we need a complete restoration (if that's even possible?). This should be a rare enough user-error that the UX isn't harmed |
6b7bbca to
beba14b
Compare
|
Makes sense, thanks. I dropped the cancel and it warns now (print outside Roblox). Nothing is restored: the thread pops its own scopes when it's resumed, the caller's scope just gets moved above them so the caller pops the right one. untrack/batch restore themselves once the thread resumes, and a component with Since yields don't error anymore, I renamed the two |
|
Thank you |
When strict mode catches a yield in a reactive scope, the update stops but the scopes pushed inside the yielded thread stay on the scope stack. A yield in a
show()component leaves theshow()effect on the stack, so its next update errors as if it was still running and the root can't be destroyed:Strict mode now warns on a yield instead of erroring (print outside Roblox) and leaves the thread to finish on its own. The thread pops the scopes it pushed once it's resumed, so the caller's scope is moved above them for the caller to pop. The rest of the update carries on, so the component above shows up after
task.wait()like it does without strict mode. An error after the thread resumes is rethrown from the thread, since there is no caller left to return it to.