Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

[πŸ› Bug]: cloudflare broken with Next ^5.2.0 [await fetch]Β #956

@gavan-x

Description

@gavan-x

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>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions