Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find dialect at #17295

Open
1 of 4 tasks
Kaliph opened this issue Apr 26, 2024 · 2 comments
Open
1 of 4 tasks

Unable to find dialect at #17295

Kaliph opened this issue Apr 26, 2024 · 2 comments
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@Kaliph
Copy link

Kaliph commented Apr 26, 2024

Bug Description

I am using sequelize and @fyreware/mysql-data-api to connect to a AWS Aurora mysql database. When using Node.js 16
everything works just fine. As soon as I upgrade the AWS Lambda version to Node.js 18 or higher, I get the following error message. When I run my code in serverless-offline lambda emulator also on Node.js 20 I can´t reproduce the issue.
In my case I can only reproduce it running my code in AWS Lambda function at the moment.
I found another thread on Stackoverflow. Seems it is not only me, facing this issue.
issue on stackoverflow

{
  "errorType": "Error",
  "errorMessage": "Unable to find dialect at @fyreware/mysql-data-api",
  "trace": [
    "Error: Unable to find dialect at @fyreware/mysql-data-api",
    "    at ConnectionManager._loadDialectModule (/var/task/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:53:17)",
    "    at new ConnectionManager (/var/task/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:30:21)",
    "    at new MysqlDialect (/var/task/node_modules/sequelize/lib/dialects/mysql/index.js:13:30)",
    "    at new Sequelize (/var/task/node_modules/sequelize/lib/sequelize.js:194:20)",
    "    at file:///var/task/config/db.js:9:19",
    "    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)",
    "    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)",
    "    at async _tryAwaitImport (file:///var/runtime/index.mjs:1008:16)",
    "    at async _tryRequire (file:///var/runtime/index.mjs:1057:37)",
    "    at async _loadUserApp (file:///var/runtime/index.mjs:1081:16)"
  ]
}

Reproducible Example

const sequelize = new Sequelize(env.AWS_DATA_API_DATABASE_NAME, env.DATABASE_USERNAME, env.AWS_DATA_API_SECRET_ARN, {
  host: env.AWS_DATA_API_RESOURCE_ARN,
  port: env.DATABASE_PORT,
  logging: env.DATABASE_LOGGING,
  freezeTableName: env.DATABASE_FREEZE_TABLE_NAME,
  dialect: env.DATABASE_DIALECT,
  dialectOptions: {
    connectTimeout: 1000
  },
  dialectModulePath: '@fyreware/mysql-data-api',
  pool: env.DATABASE_POOL,
  query: { raw: true },
  define: {
    timestamps: env.DATABASE_TIMESTAMPS,
    underscored: env.DATABASE_UNDERSCORED,
  }
});

What do you expect to happen?

Connection to the database is established

What is actually happening?

Connection fails

Environment

  • Sequelize version: 6.37.3
  • Node.js version: > 18.x
  • If TypeScript related: TypeScript version:
  • Database & Version: AWS Aurora mysql serverless
  • Connector library & Version: mysql2 3.9.7

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.

Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.

@Kaliph Kaliph added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels Apr 26, 2024
@DorianMazur
Copy link

DorianMazur commented Apr 26, 2024

What version of serverless-offline are you using?
Recently I published new version v13.4.0 -> https://github.com/dherault/serverless-offline/releases/tag/v13.4.0
This version updates all docker images, because https://github.com/lambci/docker-lambda images are deprecated.

@Kaliph
Copy link
Author

Kaliph commented Apr 27, 2024

@DorianMazur I am using the latest version of serverless-offline 13.4.0. But my code works properly with serverless-offline.
It just happens in AWS Lambda function with Node.js version v18 or v20. With Node.js 16 everything works well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

2 participants