-
Notifications
You must be signed in to change notification settings - Fork 16
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
kysely-planetscale causes fetch to fail due to SSL version #25
Comments
Hey! I'm not sure what would cause this specifically, likely something about the fetch implementation in your runtime environment or something that Next/Vercel are changing during the build. It is possible to override the fetch implementation used by The options passed to export const queryBuilder = new Kysely<Database>({
dialect: new PlanetScaleDialect({
url: process.env.DATABASE_URL,
fetch: yourFetchOverride
})
}); |
Thanks much, Jacob. I gave that a good try with ChatGPT helping me, but even with different fetch providers it still seems to hit the SSL issue. Is there a way I can / should specify the CA certificate Kysely like
or
or something? |
I don't think it's supposed to work like that... one question, you said this is also happening locally: are you using the same |
Actually I think that's the same endpoint for mysql too, at least for my database - is that the hostname you're using? |
Yep, mine looks like that and is hosted on AWS. The connection works fine if I'm using Planet Scale CLI or mysql command line. It's just the Next.js implementation that seems... impossible. As of 2 hours ago I had to finally give up and pivot to a totally different approach but if there's a solution I'm happy to switch back. |
@jgaltio One other thing to check, are you specifying a port in your I was able to get that template to work by doing the following:
If it's still broken and you happen to have a repo that reproduces the issue, I'm happy to take a look at that. |
Running into the same problem using the local Planetscale CLI. |
@jln13x that's not a valid database URL for the PlanetScale serverless driver (which uses HTTP rather than the MySQL protocol) - to my knowledge, the local PlanetScale CLI doesn't support the serverless driver like they do the MySQL one. There's an open issue tracking that here: planetscale/database-js#110. If you want to use Kysely with local MySQL / the PlanetScale CLI, the built-in Kysely MySQL dialect works for that. |
I thought I had tried with and without the port, but I will confirm. I tried local and remote MySQL but will focus on remote only now. |
Hey! +1 to what @jacobwgillespie said. Definitely don't include the port when using database-js. If you try to connect through a default MySQL port like 3306 today, you are going to have issues similar to this. Here's a similar issue in the database-js repo that might help out: planetscale/database-js#142 I would recommend copying it directly from the UI, from Connect modal: Also, we actually include Kysely specific examples in our new onboarding. We don't reshow it in the UI again right now, but if you go to |
Tangentially related, but if you're interested in experimenting with something I've casually been working on: https://github.com/mattrobenolt/ps-http-sim This provides the HTTP shim that you can run locally to pair with a local MySQL database. |
I came across the same problem. I found out that when you directly paste the content of your new Kysely<Database>({
dialect: new PlanetScaleDialect({
url: 'mysql://o8jh6w53y.....horized":true}',
format: SqlString.format
})
}); It works as expected. But when you use It looks like the process.env.DATABASE_URL is not available in the edge lambda {
DATABASE_URL: undefined,
url: 'mysql://o8jh6w5...thorized":true}'
} That's the problem we are facing |
Found a way to fix that issue. Take a look at this: https://qwik.dev/docs/env-variables/#accessing-the-environment-variables-in-serverfull-architecture-exampleexpress |
I'm going to close this issue since SSL errors are usually caused either by an incorrect server URL value, or the runtime environment, not this driver directly. |
Using this template: https://github.com/vercel/nextjs-planetscale-nextauth-tailwindcss-template
Fetch fails (this example is from a Canary version of Next.js but I tried numerous versions):
It seems the underlying issue is to do with how Kysely handles SSL...
If I use mysql2 instead it works, however I wanted to use your lib like the template intends. Any idea what's going on with this or how to resolve it? It happens both locally and on Vercel.
This is how the library is being used:
The text was updated successfully, but these errors were encountered: