Skip to content

Routing completes before new page component has sent anything #1437

@rmarscher

Description

@rmarscher

I have an example project to test behavior when changing routes for dynamic RSC pages that take a long time to start sending data. It has a static layout with <Suspense> wrapping the {children} and adds a five second delay to the getData function that is awaited in the page server components.

It is working as expected in v0.21.20. The suspense boundary preserves it's content while navigating and the url location and layout does not update to the new route until the server component has retrieved it's initial data and starts streaming content. https://waku-long-ttfb.martiandev.workers.dev/

When I update this project to v0.23.1, the route changes immediately and the layout shows the suspense fallback again until the new page starts sending content.

I thought this was because the startTransition was removed from Link when there is no unstable_pending component. I thought that adding an unstable_pending prop to re-enable the default startTransition would give it the same behavior as before. However, that seems to cause it to show the last rendered version of the new page while it is loading (if that page is in the cache). Almost like SWR behavior. I added header links with and without unstable_pending in a branch that updates the example to v0.23.1 - https://waku-long-ttfb-updated.martiandev.workers.dev/.

It seems that the layout's children element slot is getting updated to the new page right away and maybe it didn’t used to do that? So now, when React startTransition is used, it shows the previously rendered version of the new page instead of continuing to show the previously rendered version of the current page?

I think this is unintended behavior. The routing completes before the server has sent any content for the new page. The new routing "complete" event fires and the promises accessible from the unstable_enhanceCreateData Router prop all resolve as soon as the server returns a response -- but that is well before the new page RSC has sent anything. Thanks a lot for helping to look into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions