duckdb / duckdb-wasm

WebAssembly version of DuckDB
https://shell.duckdb.org
MIT License
1.02k stars 110 forks source link

duckdb_blocking createDuckDB Cannot read properties of undefined (reading 'mainModule') #1719

Open seeya opened 2 months ago

seeya commented 2 months ago

What happens?

Initializing duckdb_blocking throws an undefined (reading 'mainModule') error.

To resolve it, I had to do this.

  let db = await duckdb_blocking.createDuckDB(
    **{ eh: DUCKDB_BUNDLES },**
    logger,
    duckdb_blocking.BROWSER_RUNTIME
  );

The issue should stem from here where it checks if the bundles.eh exists. https://github.com/duckdb/duckdb-wasm/blob/b4d2182e70b3bbf9f7cc5ac7f7d45fa94396adeb/packages/duckdb-wasm/src/targets/duckdb-browser-blocking.ts#L23

To Reproduce

I created a sandbox here: https://codesandbox.io/p/sandbox/bold-goldwasser-cgzhvv

import * as duckdb from "@duckdb/duckdb-wasm";
import * as duckdb_blocking from "@duckdb/duckdb-wasm/blocking";

async function instantiate(duckdb) {
  const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
  const DUCKDB_BUNDLES = await duckdb.selectBundle(JSDELIVR_BUNDLES);

  const logger = new duckdb_blocking.VoidLogger();
  let db = await duckdb_blocking.createDuckDB(
    **DUCKDB_BUNDLES**,
    logger,
    duckdb_blocking.BROWSER_RUNTIME
  );
  await db.instantiate((_) => {});

  return db;
}

Browser/Environment:

Chrome

Device:

macOS

DuckDB-Wasm Version:

1.28.0

DuckDB-Wasm Deployment:

browser

Full Name:

seeya

Affiliation:

None