next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Using 'use client' causes infinite loop requests to the backend interface

Open JsonLYH opened this issue 1 month ago • 2 comments

Link to the code that reproduces this issue

https://github.com/JsonLYH/next-core-demo/tree/90b82b52626d5f8c606e2d268dd265e9a0aaedc9/app/(bug)/bug

To Reproduce

Image Image

Current vs. Expected behavior

You shouldn't keep requesting backend interfaces

Provide environment information

"dependencies": {
    "babel-plugin-react-compiler": "^1.0.0",
    "next": "16.0.7",
    "react": "19.2.0",
    "react-dom": "19.2.0"
  },

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

Not sure

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

Other (Deployed)

Additional context

No response

JsonLYH avatar Dec 10 '25 03:12 JsonLYH

Broswer Console Warning: Only Server Components can be async at the moment.

Client components are used for interaction, and asynchronous logic is implemented through useEffect, and cannot be directly defined as an async function itself.

https://nextjs.org/docs/app/getting-started/server-and-client-components

xuerzong avatar Dec 10 '25 06:12 xuerzong

Hi, client components can't be async.

What are you trying to accomplish here?

icyJoseph avatar Dec 10 '25 09:12 icyJoseph

Hi, client components can't be async.

What are you trying to accomplish here? I just want to try and see if there will be any errors in writing that does not meet the requirements

JsonLYH avatar Dec 13 '25 04:12 JsonLYH

Hi, client components can't be async.

What are you trying to accomplish here?

The result is not an error, but an infinite loop request to the backend interface

JsonLYH avatar Dec 13 '25 04:12 JsonLYH

Mm yeah, I'd rephrase the title to, build step should error when async components are present in client graph, or something like that.

I am no expert on the bundler internals, but it feels like the bundler should be able to warn about the async Page on static analysis. This pattern is not supported, and it leads to a lot weird errors.

icyJoseph avatar Dec 15 '25 11:12 icyJoseph