Skip to content
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

Window hangs when ref is assigned to a promise that was just created #12346

Closed
florian-g2 opened this issue Nov 7, 2024 · 2 comments
Closed

Comments

@florian-g2 florian-g2 changed the title Runtime hangs when ref is assigned to a promise that was just created Window hangs when ref is assigned to a promise that was just created Nov 7, 2024
@florian-g2
Copy link
Author

florian-g2 commented Nov 7, 2024

I think the critical difference between case 1 and the bug case is when the reactivity is triggered.

Case 1:

  • Promise is created and event loop is empty.
  • Microtask for promise is called and resolves.
  • unwrap() is called.
    • unwrapRef is created
    • promise.then is called and resolves instantly
    • unwrapRef is set to "World!"
    • unwrapRef is returned
  • Vue displays the ref

Bug Case:

  • Promise is created and JS runtime is busy
  • unwrap() is called.
    • unwrapRef is created
    • promise.then is called and does NOT resolve instantly
    • unwrapRef is returned
  • event loop is empty
  • Microtask for promise is called and resolves.
  • unwrapRef is set to "World!" (triggers reactivity)
  • ??? something loops and the window hangs

@jh-leong
Copy link
Member

jh-leong commented Nov 8, 2024

This behavior is expected.

In the "Bug Case," each render creates a new promise, which updates the ref on the next tick, causing a new render and resulting in a dead loop.

@jh-leong jh-leong closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants