{"id":"fde7f4db0f607174","repo":"drizzle-team/drizzle-orm","slug":"streaming-is-not-supported-by-the-mysql-proxy-driv","errorCode":null,"errorMessage":"Streaming is not supported by the MySql Proxy driver","messagePattern":"Streaming is not supported by the MySql Proxy driver","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-orm/src/mysql-proxy/session.ts","lineNumber":186,"sourceCode":"\n\t\t\treturn data;\n\t\t}\n\n\t\tconst { rows } = await this.queryWithCache(queryString, params, async () => {\n\t\t\treturn await client(queryString, params, 'all');\n\t\t});\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\toverride iterator(\n\t\t_placeholderValues: Record<string, unknown> = {},\n\t): AsyncGenerator<T['iterator']> {\n\t\tthrow new Error('Streaming is not supported by the MySql Proxy driver');\n\t}\n}\n\nexport interface MySqlRemoteQueryResultHKT extends MySqlQueryResultHKT {\n\ttype: MySqlRawQueryResult;\n}\n\nexport interface MySqlRemotePreparedQueryHKT extends MySqlPreparedQueryHKT {\n\ttype: PreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n","sourceCodeStart":168,"sourceCodeEnd":197,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-orm/src/mysql-proxy/session.ts#L168-L197","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Replace streaming with batched reads: call .execute()/.all() with LIMIT/OFFSET or keyset pagination.","Switch to mysql2 driver if true streaming (cursor-based) is required.","Audit code for .iterator() usage when adopting mysql-proxy."],"exampleFix":"// before\nconst q = db.select().from(bigTable).prepare();\nfor await (const row of q.iterator()) { /* ... */ } // throws on mysql-proxy\n\n// after — paginate with execute()\nlet offset = 0;\nlet batch;\ndo {\n  batch = await db.select().from(bigTable).limit(1000).offset(offset);\n  for (const row of batch) { /* ... */ }\n  offset += 1000;\n} while (batch.length === 1000);","handlingStrategy":"validation","validationCode":"import { MySqlRemoteSession } from 'drizzle-orm/mysql-proxy';\n\nfunction supportsStreaming(db: any): boolean {\n  return !(db?.session instanceof MySqlRemoteSession);\n}\n\nif (!supportsStreaming(db)) {\n  // do not call .iterator(); paginate with execute() instead\n}","typeGuard":"import { MySqlRemoteSession } from 'drizzle-orm/mysql-proxy';\n\nfunction isProxySession(db: any): boolean {\n  return db?.session instanceof MySqlRemoteSession;\n}","tryCatchPattern":"try {\n  for await (const row of prepared.iterator()) { /* ... */ }\n} catch (e) {\n  if (e instanceof Error && /Streaming is not supported by the MySql Proxy driver/i.test(e.message)) {\n    // fall back to batched execute() reads\n  } else throw e;\n}","preventionTips":["When migrating to mysql-proxy, replace every .iterator() with paginated execute() calls.","Centralise large-read logic behind a function that branches on driver capability.","Document that streaming is unavailable on the proxy driver."],"tags":["mysql","mysql-proxy","streaming","iterator","unsupported"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}