Skip to content

Async modules (top-level await) render empty pages #1361

Description

@james-elicx

This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-20).

Problem

Pages that use top-level await (async modules / TLA) render empty content. The page module likely resolves to a Promise that is not being awaited before rendering, causing the page component and its data to be undefined or empty.

Expected: "hello"
Received: ""
// $('#app-value').text() is empty

Client-side rendering (CSR) also times out waiting for elements to appear.

Estimated Impact

~6 test failures.

Affected Test Suites

  • test/e2e/async-modules/index.test.ts (6 failures)

Recommendation

  1. Reproduce first in vinext's own test suite. Add a test with a page module that uses const data = await fetchSomething() at the top level and verify the page renders with the fetched data. Confirm it renders empty.

  2. Ensure async module imports are awaited. The SSR/RSC entry needs to await the module import for pages that use top-level await. Check whether Vite/Rolldown handles async module resolution during SSR, or if vinext needs to explicitly handle this in its entry generation code.

  3. Check the Vite build output. Verify whether Rolldown preserves top-level await in the SSR bundle and whether the entry properly awaits the module before accessing its exports.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions