{"id":"658191df5c1c9904","repo":"typeorm/typeorm","slug":"stream-is-not-supported-by-sqlite-driver","errorCode":null,"errorMessage":"Stream is not supported by sqlite driver.","messagePattern":"Stream is not supported by sqlite driver\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts","lineNumber":179,"sourceCode":"\n        await this.broadcaster.broadcast(\"AfterTransactionRollback\")\n    }\n\n    /**\n     * Returns raw data stream.\n     *\n     * @param query\n     * @param parameters\n     * @param onEnd\n     * @param onError\n     */\n    stream(\n        query: string,\n        parameters?: any[],\n        onEnd?: Function,\n        onError?: Function,\n    ): Promise<ReadStream> {\n        throw new TypeORMError(`Stream is not supported by sqlite driver.`)\n    }\n\n    /**\n     * Returns all available database names including system databases.\n     */\n    async getDatabases(): Promise<string[]> {\n        return Promise.resolve([])\n    }\n\n    /**\n     * Returns all available schema names including system schemas.\n     * If database parameter specified, returns schemas of that database.\n     *\n     * @param database\n     */\n    async getSchemas(database?: string): Promise<string[]> {\n        return Promise.resolve([])\n    }","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts#L161-L197","documentation":"Thrown by AbstractSqliteQueryRunner.stream because the sqlite driver family does not support streaming query results via the stream() API. SQLite returns rows as a single result set; there is no cursor/streaming primitive exposed. The method throws synchronously regardless of arguments.","triggerScenarios":"Calling `await dataSource.getRepository(User).createQueryBuilder().stream()` or `queryRunner.stream(sql, params)` on a sqlite DataSource. Also any code that generically calls .stream() across drivers.","commonSituations":"Portable/shared repository code that streams large result sets on Postgres and is reused on sqlite (e.g. tests or a local-dev sqlite profile). Generic export/ETL helpers that always stream.","solutions":["Replace streaming with batched iteration: use .find({ skip, take }) or queryBuilder .skip/.take pagination, or .getRawMany() with manual chunking on sqlite.","Gate the stream call by driver: only stream when dataSource.options.type supports it.","For large exports, stream from application-level paging instead of DB-level cursors on sqlite.","If you only need streaming in tests, run those tests against a stream-capable driver."],"exampleFix":"// before\nconst stream = await dataSource\n  .getRepository(User)\n  .createQueryBuilder()\n  .stream()\n\n// after (sqlite-compatible paging)\nconst PAGE = 1000\nlet skip = 0\nlet rows: User[]\ndo {\n  rows = await dataSource.getRepository(User).find({ skip, take: PAGE })\n  // process rows\n  skip += PAGE\n} while (rows.length === PAGE)","handlingStrategy":"validation","validationCode":"function supportsStream(ds: DataSource): boolean {\n  return !['sqlite', 'better-sqlite3', 'sqljs', 'react-native'].includes(ds.options.type as string)\n}","typeGuard":"function driverSupportsStream(ds: DataSource): boolean {\n  return supportsStream(ds)\n}","tryCatchPattern":null,"preventionTips":["Gate .stream() calls by driver type.","Use paginated finds (.skip/.take) on sqlite for large result sets.","Keep streaming code paths in postgres-only branches."],"tags":["sqlite","streaming","query","unsupported-feature"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}