turso-cli
turso-cli copied to clipboard
Local dev mode returns "Recieved an invalid baton" when using transactions with v0.92.1
After upgrade to the latest v0.92.1 version of the turso cli, and when using local db started with
turso dev -p 8765 --db-file local.db
the following code using transaction will throw an exception: LibsqlError: SERVER_ERROR: Server returned HTTP status 400: Received an invalid baton
async function initDb() {
faker.seed(123);
await db.transaction(async (tx) => {
await tx.delete(tasks);
await tx.insert(tasks).values(
Array.from({ length: 50 }, () => {
const timestamp = faker.date.recent({ days: 60 });
return {
category: faker.helpers.arrayElement(taskCategory),
status: faker.helpers.arrayElement(taskStatus),
priority: faker.helpers.arrayElement(taskPriority),
title: faker.hacker.phrase(),
createdAt: timestamp,
updatedAt: timestamp,
};
}),
);
});
}
StackTrace:
GET /tasks/reset 500 in 278ms
⨯ LibsqlError: SERVER_ERROR: Server returned HTTP status 400: Received an invalid baton
at mapHranaError (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-cjs/hrana.js:287:16)
at HttpTransaction.batch (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib-cjs/hrana.js:131:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/peng/Workspaces/playground/crud-demo/.next/server/chunks/src_2d0027._.js:324:9
at async LibSQLSession.transaction (/Users/peng/Workspaces/playground/crud-demo/.next/server/chunks/0ab5b_drizzle-orm_d2b984._.js:5706:28)
at async initDb (/Users/peng/Workspaces/playground/crud-demo/.next/server/chunks/src_2d0027._.js:322:5)
at async GET (/Users/peng/Workspaces/playground/crud-demo/.next/server/chunks/src_2d0027._.js:315:5)
at async /Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:53191
at async e_.execute (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:44492)
at async e_.handle (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:54445)
at async doRender (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1377:42)
at async cacheEntry.responseCache.get.routeKind (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1599:28)
at async DevServer.renderToResponseWithComponentsImpl (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1507:28)
at async DevServer.renderPageComponent (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1924:24)
at async DevServer.renderToResponseImpl (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1962:32)
at async DevServer.pipeImpl (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:920:25)
at async NextNodeServer.handleCatchallRenderRequest (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js:272:17)
at async DevServer.handleRequestImpl (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:816:17)
at async /Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/dev/next-dev-server.js:339:20
at async Span.traceAsyncFn (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/trace/trace.js:154:20)
at async DevServer.handleRequest (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
at async invokeRender (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:174:21)
at async handleRequest (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:353:24)
at async requestHandlerImpl (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:377:13)
at async Server.requestListener (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/lib/start-server.js:141:13) {
code: 'SERVER_ERROR',
rawCode: undefined,
[cause]: HttpServerError: Server returned HTTP status 400: Received an invalid baton
at errorFromResponse (/Users/peng/Workspaces/playground/crud-demo/node_modules/.pnpm/@[email protected]/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js:367:12)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 400
}
}
turso-cli output:
2024-04-26T01:31:52.268947Z ERROR libsql_server::hrana::http: hrana server: Invalid MAC on baton
When the db operations are moved out of a transaction, no error will occur.
The code worked without any problem as of a few days ago where v0.91.x should have been used. The libsql-servers has not been upgraded since over two weeks ago.
~/W/p/crud-demo * ls -l /opt/homebrew/Cellar/libsql-server/ 2008ms Fri Apr 26 09:33:35 2024
total 0
drwxr-xr-x@ 7 peng admin 224 Apr 8 08:56 0.23.0/
~/W/p/crud-demo * ls -l /opt/homebrew/Cellar/turso/ Fri Apr 26 09:39:13 2024
total 0
drwxr-xr-x 7 peng admin 224 Apr 25 22:48 0.92.1/
The code does not throws exceptions when connecting to the db from turso.