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]: getRequestContext in root layout says it needs to be on edge runtime even though that has been set #907

Open
1 task
eliw00d opened this issue Nov 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@eliw00d
Copy link

eliw00d commented Nov 24, 2024

next-on-pages environment related information

System:
Platform: linux
Arch: x64
Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
CPU: (16) x64 AMD Ryzen 7 7800X3D 8-Core Processor
Memory: 15 GB
Shell: /usr/bin/zsh
Package Manager Used: npm (10.9.0)

Relevant Packages:
@cloudflare/next-on-pages: 1.13.5
vercel: 39.1.1
next: 15.0.3

Description

Currently, if I set runtime in my root layout to edge and call a lib function that uses getRequestContext to initialize my database, I get the following error:

▲  Error: `getRequestContext` and `getOptionalRequestContext` can only be run
▲  inside the edge runtime, so please make sure to have included
▲  `export const runtime = 'edge'` in all the routes using such functions
▲  (regardless of whether they are used directly or indirectly through imports).

If I do the same thing in a page, it works.

Reproduction

import { initializeDatabase } from '@/lib/utilities'

export const runtime = 'edge'

export default async function RootLayout({ children }: PropsWithChildren) {
  await initializeDatabase() // throws an error

  ...
}

Pages Deployment Method

Direct Upload (wrangler pages publish or the @cloudflare/pages-action GitHub Action)

Pages Deployment ID

No response

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
@eliw00d eliw00d added the bug Something isn't working label Nov 24, 2024
@eliw00d eliw00d changed the title [🐛 Bug]: [🐛 Bug]: getRequestContext in root layout says it needs to be on edge runtime even though that has been set Nov 24, 2024
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