Cannot access `AsyncLocalStorage` when using default fetch export API

I’m getting an AsyncLocalStorage issue after updating my package @domcojs/vercel to utilize the new default fetch export API for the function. Instead of converting Web to Node within the package, the build just exports an object with a web standard fetch method now instead.

You can see the error occur here.
Link to repository

Context.get is calling AsyncLocalStorage.getStore within the ovr package.

Works in dev, preview, and my prerendered pages during build are rendered correctly.

Hey, Ross! Welcome to the Vercel Community.

One suggestion I’d have is to force the Node.js runtime by adding this to your function:

export const runtime = 'nodejs';

export default async function handler(req: Request) {
  // your fetch handler code
}

This ensures it runs in the Node.js runtime instead of Edge.

Could you give that a go?

Got it, I think that’s what I misunderstood. So the default fetch export mentioned here Functions API Reference still runs on Edge functions instead of Node? I was trying to use this fetch API but also have access to the Node APIs. I’d like to remove some code I have the converts the Node request/response into the web standard and back.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.