Skip to content

OrbitDB incompatible with streaming blockstores (js-stores PR #358) #1244

Open

Description

@NiKrause

Issue: OrbitDB incompatible with streaming blockstores

Description

OrbitDB fails when used with blockstores that return async iterables (streams) instead of Uint8Arrays. This is due to a breaking change introduced in js-stores PR #358 , which allows blockstores to return streams.

Note: This issue commonly manifests when upgrading to libp2p v3, as libp2p v3 uses blockstores that implement the new streaming format. However, the root cause is the blockstore format change, not libp2p v3 itself.

Error

When using blockstores that return async iterables, OrbitDB throws errors like:

  • CBOR decode error: data to decode must be a Uint8Array
  • fns.shift(...) is not a function (in sync.js when using it-pipe)

Root Cause

js-stores PR #358 introduced streaming blockstores where blockstore.get() can return:

  • Uint8Array (traditional)
  • AsyncIterable<Uint8Array> (new streaming format)
  • Promise<Uint8Array | AsyncIterable<Uint8Array>>

OrbitDB currently assumes storage.get() always returns Uint8Array directly or via a Promise, but doesn't handle async iterables.

Affected Code

All places where storage.get() or blockstore.get() is called:

  • src/oplog/oplog-store.js
  • src/storage/ipfs-block.js
  • src/oplog/heads.js
  • src/manifest-store.js
  • src/key-store.js
  • src/identities/identities.js
  • src/access-controllers/ipfs.js
  • src/sync.js

Solution

Create a utility function toUint8Array() that:

  1. Returns Uint8Array as-is
  2. Awaits Promise results and processes them
  3. Collects chunks from AsyncIterable and concatenates to Uint8Array
  4. Handles other buffer-like types

Then update all storage.get() calls to use await toUint8Array(storage.get(...)).

Versions

  • @orbitdb/core: 3.0.2
  • blockstore-core: 6.1.1+ (with streaming support)
  • libp2p: 3.0.2+ (commonly triggers this issue)
  • helia: 6.0.8+

Related

Activity

  1. mar1n3r0 commented on Dec 30, 2025

    @mar1n3r0

    Just switched from go-orbit-db to orbit-db and stumbled upon this. Is there any solution to this, for example pinning certain versions until it's fixed?

    For example I tried to use helia pinned to 5.3.0 like in orbit-db dependencies and it reaches for a public gateway with a 504.

  2. NiKrause commented on Jan 1, 2026

    @NiKrause
    ContributorAuthor

    Happy New Year! Yes, there is a solution.

    Don't use libp2p v3 only v2 and associated Helia. libp2p v3 isn't ready yet.

    You can go to my profile checkout simple-todo example for a working libp2p v2 dependency stack including Helia. Let me know if it helped.

    Or checkout the lift-off example from OrbitDB repo here, not sure tho how old and complete it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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