tursodatabase/turso · error · DatabaseError

missing batch result in pipeline response

Error message

missing batch result in pipeline response

What it means

The serverless session sends a batch as a pipeline request and expects the first pipeline result to contain the batch response. If the response has no results at all, the protocol contract is violated (server error, proxy interference, or protocol mismatch), so batch() throws a DatabaseError rather than returning garbage.

Source

Thrown at serverless/javascript/src/session.ts:616

    let response: PipelineResponse;
    try {
      response = await executePipeline(this.httpContext(queryOptions), request, this.createAbortSignal(queryOptions));
    } catch (e) {
      this.baton = null;
      this.autocommit = true;
      throw e;
    }

    this.baton = response.baton;
    if (response.base_url) {
      this.baseUrl = normalizeUrl(response.base_url);
    }
    this.updateAutocommit(response);

    const first = response.results?.[0];
    if (!first) {
      throw new DatabaseError('missing batch result in pipeline response');
    }
    if (first.type === 'error') {
      throw new DatabaseError(first.error?.message || 'Batch execution failed', first.error?.code);
    }
    if (first.response?.type !== 'batch') {
      throw new DatabaseError(`expected batch result in pipeline response, got ${first.response?.type}`);
    }
    const batchResult = first.response.result as BatchResultData | undefined;
    const stepResults = batchResult?.step_results;
    const stepErrors = batchResult?.step_errors;
    if (
      !Array.isArray(stepResults) ||
      !Array.isArray(stepErrors) ||
      stepResults.length !== steps.length ||
      stepErrors.length !== steps.length
    ) {
      throw new DatabaseError('batch response does not have one result and one error per step');
    }

View on GitHub (pinned to c1e5928725)

Solutions

  1. Log the raw HTTP response body to see what the server actually returned.
  2. Upgrade the @tursodatabase/serverless client and server to matching versions.
  3. Verify baseUrl points at a genuine Turso HTTP endpoint and no proxy strips the body.
  4. Retry the batch; if persistent, report with the raw response payload.
Defensive patterns

Strategy: retry

Validate before calling

null

Try / catch

try { await session.batch(stmts); } catch (e) { if (e instanceof DatabaseError && e.message === 'missing batch result in pipeline response') { /* log raw response, retry once, then fail */ } else throw e; }

Prevention

When it happens

Trigger: Calling session.batch() and receiving a pipeline response whose results array is empty or undefined — typically a server-side failure, an incompatible server version, or a truncated/intercepted HTTP response.

Common situations: Hitting the database through a proxy/load balancer that rewrites responses, pointing the client at a non-Turso or outdated endpoint, server crashes mid-pipeline.

Related errors


AI-assisted analysis of tursodatabase/turso@c1e5928725 (2026-08-31). Data as JSON: /api/errors/f060e26df9d55c3b. Report an issue: GitHub.