tursodatabase/turso · error · DatabaseError
Sequence execution failed
Error message
Sequence execution failed
What it means
The pipeline response for session.sequence(sql) returned an error-typed result for the multi-statement string. The literal is the fallback when the server error carries no message; the thrown DatabaseError normally includes the server's message and code. Any single failing statement in the semicolon-separated payload fails the whole sequence call.
Solutions
- Split the script on semicolons and execute statements one by one to find the failing one
- Read the thrown error's message and code for the exact server complaint
- Fix or reorder the offending statement (e.g. CREATE TABLE before the INSERT that uses it)
- For migration files, prefer batch() or per-statement execution with individual error reporting
Example fix
// before
await session.sequence(schemaSql); // one statement fails, whole call fails
// after
for (const stmt of schemaSql.split(';').map(s => s.trim()).filter(Boolean)) {
await session.execute(stmt);
} Defensive patterns
Strategy: try-catch
Type guard
import { DatabaseError } from '@tursodatabase/serverless';
function isSequenceError(e: unknown): e is DatabaseError {
return e instanceof DatabaseError && e.message === 'Sequence execution failed';
} Try / catch
try {
await session.sequence(schemaSql);
} catch (e) {
if (e instanceof DatabaseError) {
// bisect: run each statement separately to find the failing one
for (const stmt of schemaSql.split(';')) await session.execute(stmt);
}
throw e;
} Prevention
- Prefer per-statement execution (or batch with individual results) for migrations so one bad statement is identifiable
- Validate migration scripts against the target schema version before running sequence()
- Order statements so dependencies (tables) are created before their users
When it happens
Trigger: Calling sequence() with a migration or script string where any one statement is invalid or references a missing object; statements the server refuses to run via the sequence request type; a later statement depending on an earlier one that already failed.
Common situations: Feeding a .sql schema dump through sequence(); running migrations that contain a statement for a table added later in the same string; environment drift where an object exists in dev but not prod.
Related errors
- Batch execution failed
- Describe execution failed
- SQL execution failed
- SQL execution failed
- batch statement failed: is not allowed in an atomic batch
AI-assisted analysis of tursodatabase/turso@c1e5928725 (2026-08-20).
Data as JSON: /api/errors/1dcbe18cb3a7dcbb.
Report an issue: GitHub.
Appendix: source
Thrown at serverless/javascript/src/session.ts:753
try {
seqResponse = await executePipeline(this.httpContext(queryOptions), request, this.createAbortSignal(queryOptions));
} catch (e) {
this.baton = null;
this.autocommit = true;
throw e;
}
this.baton = seqResponse.baton;
if (seqResponse.base_url) {
this.baseUrl = normalizeUrl(seqResponse.base_url);
}
this.updateAutocommit(seqResponse);
// Check for errors in the response
if (seqResponse.results && seqResponse.results[0]) {
const result = seqResponse.results[0];
if (result.type === "error") {
throw new DatabaseError(result.error?.message || 'Sequence execution failed', result.error?.code);
}
}
}
/**
* Close the session.
*
* This sends a close request to the server to properly clean up the stream
* before resetting the local state.
*/
async close(): Promise<void> {
// Only send close request if we have an active baton
if (this.baton) {
try {
const request: PipelineRequest = {
baton: this.baton,
requests: [{
type: "close"View on GitHub (pinned to c1e5928725)