Skip to content

Conversation

@netbrum
Copy link
Contributor

@netbrum netbrum commented Apr 18, 2025

Changed await mysql.createConnection() to mysql.createPool()

--

When using mysql.createConnection(), the connection will end up getting closed if it's not used for longer than wait_timeout. Error message from mysql2 after a period of inactivity can be seen below:

Error: Can't add new command when connection is in closed state

Since drizzle doesn't handle any of the connection, you would need to juggle the database client and drizzle around before querying to make sure the connection to the database wasn't closed.

I haven't experienced this with postgres.js, as it's seemingly using pools by default.

If not using pools with mysql2 is intentional, please let me know, thanks.

@changeset-bot
Copy link

changeset-bot bot commented Apr 18, 2025

🦋 Changeset detected

Latest commit: 6d8467d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: Ben McCann <[email protected]>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 18, 2025

Open in StackBlitz

npx https://pkg.pr.new/sveltejs/cli/sv@537
npx https://pkg.pr.new/sveltejs/cli/svelte-migrate@537

commit: 6d8467d

Copy link
Member

@manuel3108 manuel3108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help!

@manuel3108 manuel3108 merged commit 8da5fc9 into sveltejs:main Apr 18, 2025
7 checks passed
@github-actions github-actions bot mentioned this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants