tursodatabase / libsql-client-ts

TypeScript/JavaScript client API for libSQL

Home Page:https://docs.turso.tech/sdk/ts/quickstart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@libsql/client@0.6.1 + Next.js

tomek-f opened this issue · comments

I use turso in my Next.js app (14.1.4). Config based on https://docs.turso.tech/sdk/ts/guides/nextjs
On version 0.6.0 everything is OK.
After updating to version 0.6.1, I'm getting Error: Unexpected end of JSON input

There's no info about 0.6.1 version in the Changelog

Console

Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)
    at successSteps (node:internal/deps/undici/undici:5555:27)
    at fullyReadBody (node:internal/deps/undici/undici:1665:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)
    at async getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/migrations.js:48:19)
    at async HttpClient.getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/http.js:79:38)
    at async HttpClient.execute (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/http.js:101:38)
    at async Turso (webpack-internal:///(rsc)/./src/app/turso/page.tsx:18:22)

Node/Next output

result:  Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: true,
    requestIncludesCredentials: true,
    type: 'default',
    status: 404,
    timingInfo: {
      startTime: 11683.973666,
      redirectStartTime: 0,
      redirectEndTime: 0,
      postRedirectStartTime: 11683.973666,
      finalServiceWorkerStartTime: 0,
      finalNetworkResponseStartTime: 0,
      finalNetworkRequestStartTime: 0,
      endTime: 0,
      encodedBodySize: 0,
      decodedBodySize: 0,
      finalConnectionTimingInfo: null
    },
    cacheState: '',
    statusText: 'Not Found',
    headersList: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [ URL {} ],
    body: { stream: undefined, length: undefined, source: undefined }
  },
  [Symbol(headers)]: HeadersList {
    cookies: null,
    [Symbol(headers map)]: Map(5) {
      'date' => [Object],
      'fly-request-id' => [Object],
      'server' => [Object],
      'via' => [Object],
      'content-length' => [Object]
    },
    [Symbol(headers map sorted)]: null
  }
}
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)
    at successSteps (node:internal/deps/undici/undici:5555:27)
    at fullyReadBody (node:internal/deps/undici/undici:1665:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)
    at async getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/migrations.js:48:19)
    at async HttpClient.getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/http.js:79:38)
 ⨯ unhandledRejection: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)
    at successSteps (node:internal/deps/undici/undici:5555:27)
    at fullyReadBody (node:internal/deps/undici/undici:1665:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)
    at async getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/migrations.js:48:19)
    at async HttpClient.getIsSchemaDatabase (/Users/userdave/Workspace/xyz/node_modules/.pnpm/@libsql+client@0.6.1/node_modules/@libsql/client/lib-cjs/http.js:79:38)

Same behavior on Next@14.2.3 (latest)

same for drizzle usage only drizzle-team/drizzle-orm#2417

Why was there such a breaking change from 6.0.0 to 6.0.1? @penberg

Hey @GustavoOS, sorry for that. This was a bug in the latest version and we release a fix for it. You can upgrade to 0.6.2 and this should not happen anymore.

Let me know if you have any other issues and I'll be happy to help! 😄

Fixed in 0.6.2. Thanks @giovannibenussi