drizzle-team/drizzle-orm · error · Error

Streaming is not supported by the MySql Proxy driver

Error message

Streaming is not supported by the MySql Proxy driver

What it means

An Error 'Streaming is not supported by the MySql Proxy driver' thrown by PreparedQuery.iterator() (drizzle-orm/src/mysql-proxy/session.ts:186). The mysql-proxy adapter executes a single remote callback per query and cannot yield rows incrementally, so calling .iterator() (or any API that uses it, like for-await over a select) throws synchronously.

Source

Thrown at drizzle-orm/src/mysql-proxy/session.ts:186

			return data;
		}

		const { rows } = await this.queryWithCache(queryString, params, async () => {
			return await client(queryString, params, 'all');
		});

		if (customResultMapper) {
			return customResultMapper(rows);
		}

		return rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));
	}

	override iterator(
		_placeholderValues: Record<string, unknown> = {},
	): AsyncGenerator<T['iterator']> {
		throw new Error('Streaming is not supported by the MySql Proxy driver');
	}
}

export interface MySqlRemoteQueryResultHKT extends MySqlQueryResultHKT {
	type: MySqlRawQueryResult;
}

export interface MySqlRemotePreparedQueryHKT extends MySqlPreparedQueryHKT {
	type: PreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;
}

View on GitHub (pinned to b7862528fd)

Solutions

  1. Replace streaming with batched reads: call .execute()/.all() with LIMIT/OFFSET or keyset pagination.
  2. Switch to mysql2 driver if true streaming (cursor-based) is required.
  3. Audit code for .iterator() usage when adopting mysql-proxy.

Example fix

// before
const q = db.select().from(bigTable).prepare();
for await (const row of q.iterator()) { /* ... */ } // throws on mysql-proxy

// after — paginate with execute()
let offset = 0;
let batch;
do {
  batch = await db.select().from(bigTable).limit(1000).offset(offset);
  for (const row of batch) { /* ... */ }
  offset += 1000;
} while (batch.length === 1000);
Defensive patterns

Strategy: validation

Validate before calling

import { MySqlRemoteSession } from 'drizzle-orm/mysql-proxy';

function supportsStreaming(db: any): boolean {
  return !(db?.session instanceof MySqlRemoteSession);
}

if (!supportsStreaming(db)) {
  // do not call .iterator(); paginate with execute() instead
}

Type guard

import { MySqlRemoteSession } from 'drizzle-orm/mysql-proxy';

function isProxySession(db: any): boolean {
  return db?.session instanceof MySqlRemoteSession;
}

Try / catch

try {
  for await (const row of prepared.iterator()) { /* ... */ }
} catch (e) {
  if (e instanceof Error && /Streaming is not supported by the MySql Proxy driver/i.test(e.message)) {
    // fall back to batched execute() reads
  } else throw e;
}

Prevention

When it happens

Trigger: On a mysql-proxy prepared query, calling prepared.iterator(), or using the relational/sequence APIs that internally call iterator(). For-await over a result set on a proxy-backed db triggers this.

Common situations: A developer uses db.select().from(...).iterator() or a streaming pattern for large result sets, then switches the project to the mysql-proxy driver for an edge deployment. The streaming call path no longer works.

Related errors


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /data/errors/fde7f4db0f607174.json. Report an issue: GitHub.