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

Allow uncached IO to stablize #25561

Merged
merged 1 commit into from
Nov 1, 2022

Commits on Nov 1, 2022

  1. Don't unwind stack while suspended, when possible

    Initial draft. I need to test this more.
    
    If a promise is passed to `use`, but the I/O isn't cached, we should
    still be able to unwrap it.
    
    This already worked in Server Components, and during SSR.
    
    For Fiber (in the browser), before this fix the state would get lost
    between attempts unless the promise resolved immediately in a microtask,
    which requires IO to be cached. This was due to an implementation quirk
    of Fiber where the state is reset as soon as the stack unwinds. The
    workaround is to suspend the entire Fiber work loop until the
    promise resolves.
    
    The Server Components and SSR runtimes don't require a workaround: they
    can maintain multiple parallel child tasks and reuse the state
    indefinitely across attempts. That's ideally how Fiber should work, too,
    but it will require larger refactor.
    
    The downside of our approach in Fiber is that it won't "warm up" the
    siblings while you're suspended, but to avoid waterfalls you're supposed
    to hoist data fetches higher in the tree regardless. But we have other
    ideas for how we can add this back in the future. (Though again, this
    doesn't affect Server Components, which already have the ideal
    behavior.)
    acdlite committed Nov 1, 2022
    Configuration menu
    Copy the full SHA
    401230e View commit details
    Browse the repository at this point in the history