8000 fix: mysql2 closed state (drizzle addon) by netbrum · Pull Request #537 · sveltejs/cli · GitHub
[go: up one dir, main page]

Skip to content

fix: mysql2 closed state (drizzle addon) #537

8000 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

Merged
merged 4 commits into from
Apr 18, 2025

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.

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 <322311+benmccann@users.noreply.github.com>
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
0