Skip to content

InstantiationProgressHandler reports incorrect bytesTotal #2077

@jr200

Description

@jr200

What happens?

Using react to instantiate duckdb, I pass in a basic InstantiationProgressHandler that logs to console. The output is below.

{startedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), updatedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), bytesTotal: 6285550, bytesLoaded: 9314009}
{startedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), updatedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), bytesTotal: 6285550, bytesLoaded: 9325068}


....


{startedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), updatedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), bytesTotal: 6285550, bytesLoaded: 32599231}
{startedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), updatedAt: Mon Aug 04 2025 07:51:54 GMT+0100 (British Summer Time), bytesTotal: 6285550, bytesLoaded: 32628187}

Should bytesLoaded be greater than bytesTotal? It's a small bug, but it means I can't display a trustworthy progress bar.

To Reproduce

I think I'm using standard instantiation code:

  const bundles = getJsDelivrBundles()
  const bundle = await selectBundle(bundles)

  const progressHandler = (progress: InstantiationProgress) => {
    console.log(progress)
  }

  const workerUrl = URL.createObjectURL(
    new Blob([`importScripts("${bundle.mainWorker!}");`], {
      type: 'text/javascript',
    })
  )

  const worker = new Worker(workerUrl)
  const db = new AsyncDuckDB(new ConsoleLogger(LogLevel.DEBUG), worker)
  await db.instantiate(bundle.mainModule, bundle.pthreadWorker, progressHandler)
  URL.revokeObjectURL(workerUrl)

Browser/Environment:

Vite and NextJS on Chrome

Device:

macbook pro laptop

DuckDB-Wasm Version:

1.29.1-dev132.0

DuckDB-Wasm Deployment:

local machine

Full Name:

Jayshan Raghunandan

Affiliation:

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions