tursodatabase / turso-client-php

Turso + PHP - libSQL Extension for PHP
https://turso.tech/php
MIT License
62 stars 5 forks source link

[Bug]: Laravel and Turso "Received a baton that has already been used" #7

Closed vedovelli closed 2 months ago

vedovelli commented 2 months ago

Description

I just started using Turso with my Laravel app, which is hosted by Fly.io. Every time I save a resource, I receive the exception below. Tried to Google it and at least I've found that it is unrelated to Laravel. Saw a couple of reports about similar issues on libsql Github repository.

I appreciate your support on the matter! Best regards,

Minimal Reproduction

No response

Exception or Error

HTTP request returned status code 400: Received a baton that has already been used (Connection: turso, SQL: update "sessions" set "payload" = YTo0OntzOjY6Il90b2tlbiI7czo0MDoiN0wxajBERHU1dDR2NnhSSTZzMkplbGpDcnNXZ1R0aEQ1MXNZWDh6dyI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MjtzOjk6Il9wcmV2aW91cyI7YToxOntzOjM6InVybCI7czo0OToiaHR0cHM6Ly9nZXN0YW8tc2ltcGxlcy5mbHkuZGV2L3VzdWFyaW8vNC9kZXRhbGhlcyI7fX0=, "last_activity" = 1724423438, "user_id" = 2, "ip_address" = 2804:7f0:bec1:e684:e9a8:42ab:53b7:12d3, "user_agent" = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 where "id" = Y38GfuDAWEHdYeeDFQ4tODYurOUVpJVEkV9mpX2x)
darkterminal commented 2 months ago

Did you use turso-driver-laravel? And is any related Laravel Ecosystem integration?

vedovelli commented 2 months ago

@darkterminal thanks for your reply!

I am using https://github.com/richan-fongdasen/turso-laravel

darkterminal commented 2 months ago

Hi @vedovelli, That's great! But, my question is:

HTTP request returned status code 400: Received a baton that has already been used (Connection: turso, SQL: update "sessions" set "payload" = YTo0OntzOjY6Il90b2tlbiI7czo0MDoiN0wxajBERHU1dDR2NnhSSTZzMkplbGpDcnNXZ1R0aEQ1MXNZWDh6dyI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MjtzOjk6Il9wcmV2aW91cyI7YToxOntzOjM6InVybCI7czo0OToiaHR0cHM6Ly9nZXN0YW8tc2ltcGxlcy5mbHkuZGV2L3VzdWFyaW8vNC9kZXRhbGhlcyI7fX0=, "last_activity" = 1724423438, "user_id" = 2, "ip_address" = 2804:7f0:bec1:e684:e9a8:42ab:53b7:12d3, "user_agent" = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 where "id" = Y38GfuDAWEHdYeeDFQ4tODYurOUVpJVEkV9mpX2x)

Connection: turso is there? Did I write the documentation wrong? Which type of connection you're using?

Please clarify, so I know what I need to fix. Thanks for the feedback.

vedovelli commented 2 months ago

I have this on my Laravel's config/database.php

    'connections' => [

        'turso' => [
            'driver' => 'turso',
            'db_url' => env('DB_URL', 'http://localhost:8080'),
            'access_token' => env('DB_ACCESS_TOKEN'),
            'db_replica' => env('DB_REPLICA'),
            'database' => null, // Leave this null
            'prefix' => env('DB_PREFIX', ''),
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
            'sticky' => env('DB_STICKY', true),
        ],

The connection is working: my app can access my database. It's just this issue with the baton and the sessions table! thank you.

darkterminal commented 2 months ago

Btw, this config doesn't look like turso-driver-laravel

vedovelli commented 2 months ago

Thank you for your time, @darkterminal ! Have a great weekend!