Skip to content

Select statement causes a "database disk image is malformed" error on web. #105

@bradleybauer

Description

@bradleybauer

Hi, I've recently switched to using the experimental WasmDatabase implementation for easy cross platform support. Everything works as expected on windows but on chrome (and firefox) I get this error after issuing a select statement.

Uncaught Error: SqliteException(11): database disk image is malformed, database disk image is malformed (code 11)
  Causing statement: SELECT * FROM market_orders_cache;

I use this code to add approximately 160,000 rows to the table

  Future<void> setOrders(Map<int, List<Order>> allOrders) async {
    await _clearCache(cache.marketOrdersCache);
    final inserts = <MarketOrdersCacheCompanion>[];
    allOrders.forEach((_, orders) {
      inserts.addAll(orders.map((o) => MarketOrdersCacheCompanion.insert(
        typeID: o.typeID,
        systemID: o.systemID,
        regionID: o.regionID,
        isBuy: o.isBuy,
        price: o.price,
        volumeRemaining: o.volumeRemaining,
      )));
    });
    await cache.batch((batch) {
      batch.insertAll(cache.marketOrdersCache, inserts);
    });
  }

Later I use a basic select statement which causes the error.

    final rows = await cache.select(cache.marketOrdersCache).get();

Here is my project for reference if needed.

The issue occurs on the latest drift and flutter master channel versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions