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

turso dev creates a sqld process on given port without checking that it is already bound to an existing process #873

Open
gamebox opened this issue Jun 14, 2024 · 2 comments

Comments

@gamebox
Copy link

gamebox commented Jun 14, 2024

TL;DR: Turso Dev should check the devPort for being bound before starting the sqld process (Maybe sqld should do this as well?).

Maybe you could call this a skill issue, but the experience of using turso dev can be a little frustrating when moving fast on your machine - especially when you are working on a number of different zero-user projects like I do.

Run

turso dev local.db

On a machine where you already have something running on port 8080 and instead of getting a friendly message like

Connection Failed: It looks like http://127.0.0.1:8080 is already bound to another process, maybe pick another port?

You get a happy message saying you are good to go!

sqld listening on port 8080.
Use the following URL to configure your libSQL client SDK for local development:

    http://127.0.0.1:8080

By default, no auth token is required when sqld is running locally. If you want to require authentication, use --auth-jwt-key-file to specify a file containing the JWT key.

Using database file local.db.

When you then try to do anything useful with it, like connect to it in your application or even run turso shell with it, you get a most cryptic error message:

Error: failed to connect to database. err: failed to execute SQL: SELECT 1;
invalid character '<' looking for beginning of value

Now, one doesn't have to have been in the game a long time to know that this probably means that turso shell sent the server at the address some SQL, and got back something unexpected - most likely some HTML, given the '<' character to start things off. But if you have skill issues, are very tired, or just not focused because you are trying to cram in working on 5 different side projects in the half hour of free time you get between the job that pays you money and spending responsible parent time with a growing family - you might just not make that connection and might make several assumptions about the Turso tooling and waste away the rest of your precious dev time for the day.

@gamebox
Copy link
Author

gamebox commented Jun 14, 2024

I am happy to contribute this change, whether it's here on the turso-cli or in libsql/sqld. I have contributed before.

@gamebox
Copy link
Author

gamebox commented Jun 14, 2024

So I've dug into this some more, and it looks like I'm more than likely going to take an L here. My older service was ListenAndServe'ing over localhost:8080 whereas sqld listens on any interface and therefore doesn't mind that localhost was bound on that port. But I'll leave it up to y'all to determine if sqld should have that behavior since it will happily leave the user in a state that can be hard to pinpoint. I can also move this issue over to libsql repo if that makes more sense, since I think turso-cli is really shelling responsibility for this to sqld.

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

No branches or pull requests

1 participant