Skip to content

v4: Unable to import sequelize/postgres #1885

Open
@steelbrain

Description

@steelbrain

Checklist

Description

I'm on v4.0.0-beta.14 and stuck. For my usecase, I need access to the database in beforeSessionSaved so I can save a userId along with some other parameters in the session context.

In v4, the callback runs in the Next.js edge runtime, which is quite a bit limited compared to the regular runtime. I am unable to use my sequelize postgres setup, here's the stack trace

upport Node.js 'tty' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
    at <unknown> (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/globals.js:43)
    at Object.apply (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/globals.js:43:19)
    at eval (webpack-internal:///(middleware)/./node_modules/colorette/index.cjs:39:61)
    at (middleware)/./node_modules/colorette/index.cjs (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/src/middleware.js:31226:1)
    at __webpack_require__ (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/edge-runtime-webpack.js:37:33)
    at fn (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/edge-runtime-webpack.js:315:21)
    at eval (webpack-internal:///(middleware)/./node_modules/pino-pretty/index.js:3:30)
    at (middleware)/./node_modules/pino-pretty/index.js (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/src/middleware.js:31248:1)
    at __webpack_require__ (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/edge-runtime-webpack.js:37:33)
    at fn (file:///Users/aneesiqbal/Projects/shw/app/projects/webapp/.next/server/edge-runtime-webpack.js:315:21)
    at eval (webpack-internal:///(middleware)/./src/server/utils/base-logger.ts:8:69)
 ⚠ ./node_modules/sequelize/lib/dialects/abstract/connection-manager.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/sequelize/lib/dialects/abstract/connection-manager.js
./node_modules/sequelize/lib/dialects/sqlite/connection-manager.js
./node_modules/sequelize/lib/dialects/sqlite/index.js
./node_modules/sequelize/lib/sequelize.js
./node_modules/sequelize/lib/index.js
./node_modules/sequelize/lib/index.mjs
./src/server/services/auth/authClient.ts

Reproduction

Not relevant given that this is a pretty well known limitation of the edge runtime

Additional context

No response

nextjs-auth0 version

4.0.0-beta.14

Next.js version

14.2.21

Node.js version

v22.11.0

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions