Error: Module not found: Can't resolve 'stream'
Import trace for requested module:
./node_modules/isomorphic-fetch/fetch-npm-node.js
./node_modules/@upstash/redis/esm/platforms/nodejs.js
./pages/api/_middleware.ts
https://nextjs.org/docs/messages/module-not-found
You're using a Node.js module (stream) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime
It seems that @upstash/redis depends on stream but it's not possible to use the stream module in a Next.js Edge function. A seperate Vercel middleware example seems to use a slimed down version of a Redis client that doesn't depend on stream , but alas I'm not sure how that would integrate with the rate limiting module.
Is there a way to use @upstash/ratelimit with Next.js Edge functions out of the box?
Copying the example provided here to our project, I get the following error:
It seems that
@upstash/redis
depends onstream
but it's not possible to use thestream
module in a Next.js Edge function. A seperate Vercel middleware example seems to use a slimed down version of a Redis client that doesn't depend onstream
, but alas I'm not sure how that would integrate with the rate limiting module.Is there a way to use
@upstash/ratelimit
with Next.js Edge functions out of the box?