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

[🐛 Bug]: cloudflare broken with Next ^5.2.0 [await fetch] #956

Open
gavan1 opened this issue Mar 11, 2025 · 0 comments
Open

[🐛 Bug]: cloudflare broken with Next ^5.2.0 [await fetch] #956

gavan1 opened this issue Mar 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@gavan1
Copy link

gavan1 commented Mar 11, 2025

next-on-pages environment related information

export default async function Page() {
  const data = await fetch('https://api.vercel.app/blog')
  const posts = await data.json()
  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  )
}

Any RSC page as documented by NEXt.js that has and top level await fetch call will cause an "internal server error" and on console.

Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/

Description

Any RSC page as documented by NEXt.js that has and top level await fetch call will cause an "internal server error"

Reproduction

export default async function Page() {
  const data = await fetch('https://api.vercel.app/blog')
  const posts = await data.json()
  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  )
}
@gavan1 gavan1 added the bug Something isn't working label Mar 11, 2025
@gavan1 gavan1 changed the title [🐛 Bug]: cloudflare broken with Next 5.2.1 [asycn fetch] [🐛 Bug]: cloudflare broken with Next 5.2.1 [await fetch] Mar 11, 2025
@gavan1 gavan1 changed the title [🐛 Bug]: cloudflare broken with Next 5.2.1 [await fetch] [🐛 Bug]: cloudflare broken with Next ^5.2.0 [await fetch] Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant