datastore-idb .query doesn't work as expected

Open
#198 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #7 by @achingbrain — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
databases

Research direction

Start by tracing store.query and its IndexedDB transaction and cursor lifecycle. Review the linked idb transaction-lifetime explanation, then reproduce a query consumer doing asynchronous work between yielded results. Done means query iteration no longer fails with an inactive-transaction DOMException.

Written by the indexing model from the issue text.

Description

kind/bug

store.query opens an IndexedDB transaction and uses a cursor to iterate over each entry in the datastore. The transaction closes automatically when the microtask queue is emptied and there's no outstanding work for it to do, even if the cursor is not at the end of the dataset.

Each query result is yielded to the caller which if they do any async work can cause the transaction to close and the next call to cursor.continue() to throw ERROR: DOMException{stack: 'Error: Failed to execute 'continue' on 'IDBCursor': The transaction is not active..

https://www.npmjs.com/package/idb/v/5.0.2#transaction-lifetime

Dominant language
TypeScript
Stars
39
Forks
28
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ipfs/js-stores

All issues in ipfs/js-stores

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.