⨯ Error [TypeError]: Cannot read properties of undefined (reading 'charCodeAt')
at [project]/node_modules/redis-errors/index.js [middleware] (ecmascript) (.next/server/edge/chunks/cf77d9..js:10373:32)
at <unknown> (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:693:27)
at runModuleExecutionHooks (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:738:9)
at instantiateModule (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:691:9)
at getOrInstantiateModuleFromParent (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:624:12)
at commonJsRequire (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:157:20)
at [project]/node_modules/ioredis/built/cluster/index.js [middleware] (ecmascript) (.next/server/edge/chunks/cf77d9..js:15112:24)
at <unknown> (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:693:27)
at runModuleExecutionHooks (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:738:9)
at instantiateModule (.next/server/edge/chunks/edge-wrapper_bf7e6c.js:691:9)
GET / 404 in 2ms
#TypeError: Cannot read properties of undefined (reading 'charCodeAt')
1 messages · Page 1 of 1 (latest)
Hi @balmy walrus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the error message you've provided, it appears you're encountering a TypeError related to Redis usage in a Next.js application using the Edge runtime. This error is likely occurring in your middleware or an API route using the Edge runtime.
The specific error "Cannot read properties of undefined (reading 'charCodeAt')" suggests that the code is trying to access a property or method of an undefined value. This could be due to incompatibility between the Redis client library and the Edge runtime.
Unfortunately, the knowledge sources provided don't contain specific information about this exact error. However, there are a few relevant points that might help:
-
Edge Runtime Compatibility: The Edge runtime has limitations on which Node.js APIs and modules can be used. Some Redis client libraries may not be fully compatible with the Edge runtime Github Issue #53562 (https://github.com/vercel/next.js/issues/53562).
-
Middleware Issues: There have been reports of similar errors occurring in middleware when using the Edge runtime Github Issue #56368 (https://github.com/vercel/next.js/issues/56368).
To resolve this issue, you could try the following:
-
Check if your Redis client library is compatible with the Edge runtime. You may need to use a different library or approach for Redis connections in Edge functions.
-
If this is occurring in middleware, you could try adding a matcher to exclude certain paths:
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
}
-
Consider using the Node.js runtime instead of the Edge runtime for parts of your application that require Redis, if possible.
-
Ensure you're using the latest version of Next.js, as some issues may have been resolved in newer versions.