question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Iterating an index throwing 'is not a function or its return value is not async iterable' error

See original GitHub issue

In this section of the demo code below, I receive a ‘TypeError: index.iterate(…) is not a function or its return value is not async iterable’:

// Add 'And, happy new year!' to all articles on 2019-01-01:
  {
    const tx = db.transaction('articles', 'readwrite');
    const index = tx.store.index('date');
 
    for await (const cursor of index.iterate(new Date('2019-01-01'))) {
      const article = { ...cursor.value };
      article.body += ' And, happy new year!';
      cursor.update(article);
    }
 
    await tx.done;
  }

I am working in the latest version of Chrome (v83). The database and index are created but just having issues with this index iterate.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jakearchibaldcommented, Apr 9, 2020

Note that you need a different import for async iterators https://github.com/jakearchibald/idb#async-iterators.

Please reopen if this isn’t the issue.

0reactions
jakearchibaldcommented, Apr 9, 2020

I just noticed the import statement in the demo, that is most helpful.

Sorry it wasn’t there earlier!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The meaning of "'x' is not a function or its return value is not ...
asyncIterator implemented it will throw this error. On the first case, the Symbol it's a constant, so it's not iterable.
Read more >
TypeError: 'x' is not iterable - JavaScript - MDN Web Docs
Calling a generator produces an iterable object which will iterate over the values yielded during the execution of the generator. function* generate(a, b)...
Read more >
Problems with Example 14.6 · Issue #193 · w3c/webtransport
Error while reading from stream #1": TypeError: stream.readable.pipeThrough(...).getReader(...) is not a function or its return value is not async iterable
Read more >
Node.js v19.3.0 Documentation
If asyncFn is a function and it throws an error synchronously, assert.doesNotReject() will return a rejected Promise with that error. If the function...
Read more >
Iterables - The Modern JavaScript Tutorial
When for..of starts, it calls that method once (or errors if not found). The method must return an iterator – an object with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found