Skip to content

Fast Refresh breaks in presence of top level await #84658

@rnbrady

Description

@rnbrady

Link to the code that reproduces this issue

https://github.com/rnbrady/next-15-tla

To Reproduce

Start in dev mode with pnpm dev and open the page:

Step 1: Click to increment the counter
Step 2: Edit the message in the lib/with-tla.ts and save the file
Step 3: Return to the page, you will find the counter has been reset, meaning the Fast Refresh has failed.
Step 4: Edit the code to use lib/without-tla.ts. You will notice the counter no longer resets.

Current vs. Expected behavior

Expected:
Counter state should be preserved. Fast refresh should work.

Current:
Counter state resets. The following is shown which does not explain the problem:

[Fast Refresh] performing full reload

Fast Refresh will perform a full reload when you edit a file that's imported by modules outside of the React rendering tree. You might have a file which exports a React component but also exports a value that is imported by a non-React component file. Consider migrating the non-React component export to a separate file and importing it into both files.

It is also possible the parent component of the component you edited is a class component, which disables Fast Refresh. Fast Refresh requires at least one parent function component in your React tree.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Thu Dec 19 20:44:10 PST 2024; root:xnu-10063.141.1.703.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 24.4.1
  npm: 11.4.2
  Yarn: 3.6.0
  pnpm: 10.15.1
Relevant Packages:
  next: 15.6.0-canary.53 // Latest available version is detected (15.6.0-canary.53).
  eslint-config-next: 15.5.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

React

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Happens with and without Turbopack.

If TLA is present anywhere in projects or deps, Fast Refresh will fail everywhere, regardless of whether page being refreshed imports the TLA module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ReactRelated to React.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions