Next.js Discord

Discord Forum

How to test if code is running on edge runtime

Unanswered
Rough Collie posted this in #help-forum
Open in Discord
Rough CollieOP
Hi there, I am trying to test to see if my code is actually running on an edge runtime or using some kind of pollyfill.

I have found documentation here: https://vercel.com/docs/functions/edge-functions/edge-runtime#check-if-you're-running-on-the-edge-runtime about using "globalThis.EdgeRuntime". I have setup a API route in my "app" folder to test this however I have found that on my development environment if I declare export const runtime = "edge" at the top of the file it will report to be running on the edge runtime. From my understanding however my development environment ("next dev") the runtime is always Node with polyfills being used so I was expecting this test to report using the Node runtime despite the declaration.

When the code is built and deployed to GoogleAppEngine (cant use vercel because of compliance) it is also reporting that the Edge runtime is being used however I am very sure that GAE does not support Edge compute. Perhaps this is directly influenced by the declaration despite the runtime not being possible?

Have I misunderstood something on how this all works?
How can I test is the Edge runtime is being used regardless of declaration?

0 Replies